Skip to content

Commit

Permalink
WIP: typing
Browse files Browse the repository at this point in the history
  • Loading branch information
pajod committed Dec 18, 2023
1 parent f4adf2f commit f823579
Show file tree
Hide file tree
Showing 28 changed files with 461 additions and 314 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/buildpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
( cd workaround/ && tar --extract --file gunicorn_21.2.0.orig.tar.gz gunicorn-21.2.0 )
test -s workaround/gunicorn-21.2.0/pyproject.toml
rsync -vrlt source/.github/packaging/debian/ workaround/gunicorn-21.2.0/debian
echo 'extend-diff-ignore = "^setup\.cfg$"' > workaround/gunicorn-21.2.0/debian/source/options
echo 'extend-diff-ignore = "^setup\.cfg$"' >> workaround/gunicorn-21.2.0/debian/source/options
mv --verbose workaround/gunicorn-21.2.0/debian/setup.cfg workaround/gunicorn-21.2.0/
chmod --changes +x workaround/gunicorn-21.2.0/debian/control
ls -l workaround/gunicorn-21.2.0/
Expand Down Expand Up @@ -96,8 +96,20 @@ jobs:
test -s debian/gunicorn-21.2.0/debian/control
test -d debian/gunicorn-21.2.0/tests
( cd debian/gunicorn-21.2.0/ && dpkg-buildpackage --unsigned-source --unsigned-changes )
cp --verbose --archive debian/*.deb upload/
- uses: actions/upload-artifact@v3
# note that Ubuntu 22.04 does not allow zstd in dpkg tools
cp --verbose --archive debian/*.{deb,tar.gz,tar.xz,tar.zstd,buildinfo,changes,dsc} upload/
- uses: actions/upload-artifact@v4
with:
path: upload
name: dist
path: |
upload/*.deb
upload/*.tar.gz
upload/*.tar.xz
upload/*.tar.zstd
upload/*.buildinfo
upload/*.changes
upload/*.dsc
name: deb
retention-days: 5
# deb and source tarball are already compressed
compression-level: 0
if-no-files-found: error
10 changes: 8 additions & 2 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ jobs:
# windows doe not do --archive --verbose on cp
cp dist/*.tar.gz upload/
cp dist/*.whl upload/
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: upload
path: |
upload/*.tar.gz
upload/*.whl
name: dist
retention-days: 7
# sdist.tar.gz and bdist.whl are compressed by default
compression-level: 0
if-no-files-found: error
2 changes: 1 addition & 1 deletion gunicorn/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from _typeshed import Incomplete

version_info: Incomplete
version_info: tuple[int, int, int]
__version__: str
SERVER: str
SERVER_SOFTWARE: str
31 changes: 18 additions & 13 deletions gunicorn/app/base.pyi
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
from argparse import ArgumentParser, Namespace

from _typeshed import Incomplete
from _typeshed.wsgi import WSGIApplication as _WSGIApplication

from gunicorn import debug as debug
from gunicorn import util as util
from gunicorn.arbiter import Arbiter as Arbiter
from gunicorn.config import Config as Config
from gunicorn.config import Config
from gunicorn.config import get_default_config_file as get_default_config_file

# from abc import abstractmethod, ABCMeta

class BaseApplication:
usage: Incomplete
cfg: Incomplete
callable: Incomplete
prog: Incomplete
usage: str | None
cfg: Config
callable: None | _WSGIApplication
prog: str | None
logger: Incomplete
def __init__(self, usage: Incomplete | None = ..., prog: Incomplete | None = ...) -> None: ...
def __init__(self, usage: str | None = ..., prog: str | None = ...) -> None: ...
def do_load_config(self) -> None: ...
def load_default_config(self) -> None: ...
def init(self, parser, opts, args) -> None: ...
def load(self) -> None: ...
def init(self, parser: ArgumentParser, opts: Namespace, args: list[str]) -> None: ...
def load(self) -> _WSGIApplication: ...
def load_config(self) -> None: ...
def reload(self) -> None: ...
def wsgi(self): ...
def wsgi(self) -> _WSGIApplication: ...
def run(self) -> None: ...

class Application(BaseApplication):
def chdir(self) -> None: ...
def get_config_from_filename(self, filename): ...
def get_config_from_module_name(self, module_name): ...
def load_config_from_module_name_or_filename(self, location): ...
def load_config_from_file(self, filename): ...
def get_config_from_filename(self, filename: str) -> Config: ...
def get_config_from_module_name(self, module_name: str) -> Config: ...
def load_config_from_module_name_or_filename(self, location: str) -> Config: ...
def load_config_from_file(self, filename: str) -> Config: ...
def load_config(self) -> None: ...
def run(self) -> None: ...
9 changes: 6 additions & 3 deletions gunicorn/app/pasterapp.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from _typeshed import Incomplete
from _typeshed.wsgi import WSGIApplication as _WSGIApplication

from gunicorn.app.wsgiapp import WSGIApplication as WSGIApplication
from gunicorn.config import get_default_config_file as get_default_config_file

def get_wsgi_app(config_uri, name: Incomplete | None = ..., defaults: Incomplete | None = ...): ...
def has_logging_config(config_file): ...
def serve(app, global_conf, **local_conf): ...
def get_wsgi_app(
config_uri: str, name: Incomplete | None = ..., defaults: Incomplete | None = ...
) -> _WSGIApplication: ...
def has_logging_config(config_file: str) -> bool: ...
def serve(app: _WSGIApplication, global_conf: dict[str, Incomplete], **local_conf: Incomplete) -> None: ...
13 changes: 8 additions & 5 deletions gunicorn/app/wsgiapp.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from argparse import ArgumentParser, Namespace

from _typeshed import Incomplete
from _typeshed.wsgi import WSGIApplication as _WSGIApplication

from gunicorn import util as util
from gunicorn.app.base import Application as Application
from gunicorn.errors import ConfigError as ConfigError

class WSGIApplication(Application):
app_uri: Incomplete
def init(self, parser, opts, args) -> None: ...
def init(self, parser: ArgumentParser, opts: Namespace, args: list[str]) -> None: ...
def load_config(self) -> None: ...
def load_wsgiapp(self): ...
def load_pasteapp(self): ...
def load(self): ...
def load_wsgiapp(self) -> _WSGIApplication: ...
def load_pasteapp(self) -> _WSGIApplication: ...
def load(self) -> _WSGIApplication: ...

def run() -> None: ...
def run(prog: str | None = ...) -> None: ...
13 changes: 10 additions & 3 deletions gunicorn/debug.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from collections.abc import Container
from types import FrameType
from typing import Any, Literal

from _typeshed import Incomplete
from typing_extensions import Self

class Spew:
trace_names: Incomplete
show_values: Incomplete
def __init__(self, trace_names: Incomplete | None = ..., show_values: bool = ...) -> None: ...
def __call__(self, frame, event, arg): ...
def __init__(self, trace_names: Container[str] | None = ..., show_values: bool = ...) -> None: ...
def __call__(
self, frame: FrameType, event: Literal["call", "line", "return", "exception", "opcode"], arg: Any
) -> Self: ...

def spew(trace_names: Incomplete | None = ..., show_values: bool = ...) -> None: ...
def spew(trace_names: Container[str] | None = ..., show_values: bool = ...) -> None: ...
def unspew() -> None: ...
4 changes: 2 additions & 2 deletions gunicorn/errors.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from _typeshed import Incomplete

class HaltServer(BaseException):
reason: Incomplete
exit_status: Incomplete
reason: str
exit_status: int
def __init__(self, reason: str, exit_status: int = ...) -> None: ...

class ConfigError(Exception): ...
Expand Down
17 changes: 10 additions & 7 deletions gunicorn/glogging.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
from _typeshed import Incomplete
import socket
from logging import Logger as _Logger
from logging.config import _DictConfigArgs
from typing import Literal

from gunicorn import util as util
from _typeshed import Incomplete

SYSLOG_FACILITIES: Incomplete
CONFIG_DEFAULTS: Incomplete
SYSLOG_FACILITIES: dict[str, int]
CONFIG_DEFAULTS: _DictConfigArgs

def loggers(): ...
def loggers() -> list[_Logger]: ...

class SafeAtoms(dict):
def __init__(self, atoms) -> None: ...
def __getitem__(self, k): ...

def parse_syslog_address(addr): ...
def parse_syslog_address(addr: str) -> tuple[socket.SocketKind, tuple[str, int]]: ...

class Logger:
LOG_LEVELS: Incomplete
Expand Down Expand Up @@ -39,6 +42,6 @@ class Logger:
def log(self, lvl, msg, *args, **kwargs) -> None: ...
def atoms(self, resp, req, environ, request_time): ...
def access(self, resp, req, environ, request_time) -> None: ...
def now(self): ...
def now(self) -> str: ...
def reopen_files(self) -> None: ...
def close_on_exec(self) -> None: ...
63 changes: 34 additions & 29 deletions gunicorn/http/body.pyi
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
from collections.abc import Generator
from collections.abc import Generator, Iterator
from io import BytesIO

from _typeshed import Incomplete
from typing_extensions import Protocol, Self

from gunicorn.http.errors import ChunkMissingTerminator as ChunkMissingTerminator
from gunicorn.http.errors import InvalidChunkSize as InvalidChunkSize
from gunicorn.http.errors import NoMoreData as NoMoreData
from gunicorn.http.errors import ChunkMissingTerminator, InvalidChunkSize, NoMoreData
from gunicorn.http.message import Message
from gunicorn.http.unreader import Unreader

class _Read(Protocol):
def read(self, size: int) -> bytes: ...

class ChunkedReader:
req: Incomplete
req: Message
parser: Incomplete
buf: Incomplete
def __init__(self, req, unreader) -> None: ...
def read(self, size): ...
def parse_trailers(self, unreader, data): ...
def parse_chunked(self, unreader) -> Generator[Incomplete, None, None]: ...
def parse_chunk_size(self, unreader, data: Incomplete | None = ...): ...
def get_data(self, unreader, buf) -> None: ...
buf: BytesIO
def __init__(self, req: Message, unreader: Unreader) -> None: ...
def read(self, size: int) -> bytes: ...
def parse_trailers(self, unreader: Unreader, data: bytes) -> bytes: ...
def parse_chunked(self, unreader: Unreader) -> Generator[bytes, None, None]: ...
def parse_chunk_size(self, unreader: Unreader, data: bytes | None = ...) -> tuple[int, bytes]: ...
def get_data(self, unreader: Unreader, buf: BytesIO) -> None: ...

class LengthReader:
unreader: Incomplete
length: Incomplete
def __init__(self, unreader, length) -> None: ...
def read(self, size): ...
unreader: Unreader
length: int
def __init__(self, unreader: Unreader, length: int) -> None: ...
def read(self, size: int) -> bytes: ...

class EOFReader:
unreader: Incomplete
buf: Incomplete
unreader: Unreader
buf: BytesIO
finished: bool
def __init__(self, unreader) -> None: ...
def read(self, size): ...
def __init__(self, unreader: Unreader) -> None: ...
def read(self, size: int) -> bytes: ...

class Body:
reader: Incomplete
buf: Incomplete
def __init__(self, reader) -> None: ...
def __iter__(self): ...
def __next__(self): ...
reader: _Read
buf: BytesIO
def __init__(self, reader: _Read) -> None: ...
def __iter__(self) -> Self: ...
def __next__(self) -> Iterator[bytes]: ...
next = __next__
def getsize(self, size): ...
def read(self, size: Incomplete | None = ...): ...
def readline(self, size: Incomplete | None = ...): ...
def readlines(self, size: Incomplete | None = ...): ...
def getsize(self, size: int) -> int: ...
def read(self, size: int | None = ...) -> bytes: ...
def readline(self, size: int | None = ...) -> bytes: ...
def readlines(self, size: int | None = ...) -> list[bytes]: ...
49 changes: 28 additions & 21 deletions gunicorn/http/errors.pyi
Original file line number Diff line number Diff line change
@@ -1,58 +1,65 @@
from _typeshed import Incomplete

from gunicorn.http.message import Message

class ParseException(Exception): ...

class NoMoreData(IOError):
buf: Incomplete
def __init__(self, buf: bytes = ...) -> None: ...

class ConfigurationProblem(ParseException):
info: str
code: int
def __init__(self, info: str) -> None: ...

class InvalidRequestLine(ParseException):
req: Incomplete
req: str
code: int
def __init__(self, req: str) -> None: ...

class InvalidRequestMethod(ParseException):
method: Incomplete
method: str
def __init__(self, method: str) -> None: ...

class InvalidHTTPVersion(ParseException):
version: Incomplete
version: str
def __init__(self, version: str) -> None: ...

class InvalidHeader(ParseException):
hdr: Incomplete
req: Incomplete
def __init__(self, hdr, req: Incomplete | None = ...) -> None: ...
hdr: str
req: Message | None
def __init__(self, hdr: str, req: Message | None = ...) -> None: ...

class InvalidHeaderName(ParseException):
hdr: Incomplete
def __init__(self, hdr) -> None: ...
hdr: str
def __init__(self, hdr: str) -> None: ...

class InvalidChunkSize(IOError):
data: Incomplete
def __init__(self, data) -> None: ...
data: bytes
def __init__(self, data: bytes) -> None: ...

class ChunkMissingTerminator(IOError):
term: Incomplete
def __init__(self, term) -> None: ...
term: bytes
def __init__(self, term: bytes) -> None: ...

class LimitRequestLine(ParseException):
size: Incomplete
max_size: Incomplete
def __init__(self, size, max_size) -> None: ...
size: int
max_size: int
def __init__(self, size: int, max_size: int) -> None: ...

class LimitRequestHeaders(ParseException):
msg: Incomplete
def __init__(self, msg) -> None: ...
msg: str
def __init__(self, msg: str) -> None: ...

class InvalidProxyLine(ParseException):
line: Incomplete
line: str
code: int
def __init__(self, line) -> None: ...
def __init__(self, line: str) -> None: ...

class ForbiddenProxyRequest(ParseException):
host: Incomplete
host: str
code: int
def __init__(self, host) -> None: ...
def __init__(self, host: str) -> None: ...

class InvalidSchemeHeaders(ParseException): ...
Loading

0 comments on commit f823579

Please sign in to comment.