From 027460f11a3883710dadd1f3b524b2feee9b0000 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 29 Mar 2023 13:28:06 +0200 Subject: [PATCH] Remove unnecessary ellipsis expressions (#9976) Ignore flake8 F821 warnings in stub files --- .flake8 | 10 ++- stdlib/concurrent/futures/process.pyi | 6 +- stdlib/concurrent/futures/thread.pyi | 6 +- stdlib/dis.pyi | 10 +-- stdlib/multiprocessing/forkserver.pyi | 2 +- stdlib/multiprocessing/resource_tracker.pyi | 2 +- stdlib/pydoc.pyi | 4 +- stdlib/random.pyi | 4 +- stdlib/typing.pyi | 22 ++---- stdlib/typing_extensions.pyi | 2 +- .../datetimerange/__version__.pyi | 2 +- stubs/colorama/colorama/ansi.pyi | 76 +++++++++---------- stubs/colorama/colorama/ansitowin32.pyi | 20 ++--- stubs/paramiko/paramiko/kex_gex.pyi | 4 +- stubs/pysftp/pysftp/__init__.pyi | 8 +- stubs/pysftp/pysftp/exceptions.pyi | 4 +- stubs/simplejson/simplejson/scanner.pyi | 16 ++-- stubs/waitress/@tests/stubtest_allowlist.txt | 3 - stubs/waitress/waitress/adjustments.pyi | 66 ++++++++-------- stubs/waitress/waitress/buffers.pyi | 28 +++---- stubs/waitress/waitress/channel.pyi | 40 +++++----- stubs/waitress/waitress/parser.pyi | 36 ++++----- stubs/waitress/waitress/proxy_headers.pyi | 6 +- stubs/waitress/waitress/receiver.pyi | 26 +++---- stubs/waitress/waitress/server.pyi | 38 +++++----- stubs/waitress/waitress/task.pyi | 68 ++++++++--------- stubs/waitress/waitress/trigger.pyi | 12 +-- stubs/waitress/waitress/utilities.pyi | 26 +++---- stubs/waitress/waitress/wasyncore.pyi | 34 ++++----- 29 files changed, 287 insertions(+), 294 deletions(-) diff --git a/.flake8 b/.flake8 index a7bbf1b55..6647e1e41 100644 --- a/.flake8 +++ b/.flake8 @@ -28,18 +28,22 @@ # F403 import *' used; unable to detect undefined names # F405 defined from star imports +# Ignored to workaround pyflakes issues with stub files +# (the bugs this rule catches are caught by our other tests anyway): +# F821 undefined name + [flake8] extend-ignore = A, D, N8, SIM, RST, TYP, E301, E302, E305, E501 per-file-ignores = *.py: E203 - *.pyi: B, E701, E741, F401, F403, F405, F822 + *.pyi: B, E701, E741, F401, F403, F405, F821, F822 # Since typing.pyi defines "overload" this is not recognized by flake8 as typing.overload. # Unfortunately, flake8 does not allow to "noqa" just a specific error inside the file itself. # https://github.com/PyCQA/flake8/issues/1079 # F811 redefinition of unused '...' - stdlib/typing.pyi: B, E701, E741, F401, F403, F405, F811, F822 + stdlib/typing.pyi: B, E701, E741, F401, F403, F405, F811, F821, F822 # Generated protobuf files include docstrings - *_pb2.pyi: B, E701, E741, F401, F403, F405, F822, Y021, Y026, Y053, Y054 + *_pb2.pyi: B, E701, E741, F401, F403, F405, F821, F822, Y021, Y026, Y053, Y054 exclude = .venv*,.git noqa_require_code = true diff --git a/stdlib/concurrent/futures/process.pyi b/stdlib/concurrent/futures/process.pyi index 56d1ff899..000e7a435 100644 --- a/stdlib/concurrent/futures/process.pyi +++ b/stdlib/concurrent/futures/process.pyi @@ -153,9 +153,9 @@ def _chain_from_iterable_of_lists(iterable: Iterable[MutableSequence[Any]]) -> A class BrokenProcessPool(BrokenExecutor): ... class ProcessPoolExecutor(Executor): - _mp_context: BaseContext | None = ... - _initializer: Callable[..., None] | None = ... - _initargs: tuple[Any, ...] = ... + _mp_context: BaseContext | None + _initializer: Callable[..., None] | None + _initargs: tuple[Any, ...] _executor_manager_thread: _ThreadWakeup _processes: MutableMapping[int, Process] _shutdown_thread: bool diff --git a/stdlib/concurrent/futures/thread.pyi b/stdlib/concurrent/futures/thread.pyi index 34d3126ab..0b00d524a 100644 --- a/stdlib/concurrent/futures/thread.pyi +++ b/stdlib/concurrent/futures/thread.pyi @@ -44,9 +44,9 @@ class ThreadPoolExecutor(Executor): _broken: bool _shutdown: bool _shutdown_lock: Lock - _thread_name_prefix: str | None = ... - _initializer: Callable[..., None] | None = ... - _initargs: tuple[Any, ...] = ... + _thread_name_prefix: str | None + _initializer: Callable[..., None] | None + _initargs: tuple[Any, ...] _work_queue: queue.SimpleQueue[_WorkItem[Any]] def __init__( self, diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index ac0c5356f..d153771e6 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -39,10 +39,10 @@ _HaveCodeType: TypeAlias = types.MethodType | types.FunctionType | types.CodeTyp if sys.version_info >= (3, 11): class Positions(NamedTuple): - lineno: int | None = ... - end_lineno: int | None = ... - col_offset: int | None = ... - end_col_offset: int | None = ... + lineno: int | None = None + end_lineno: int | None = None + col_offset: int | None = None + end_col_offset: int | None = None if sys.version_info >= (3, 11): class Instruction(NamedTuple): @@ -54,7 +54,7 @@ if sys.version_info >= (3, 11): offset: int starts_line: int | None is_jump_target: bool - positions: Positions | None = ... + positions: Positions | None = None else: class Instruction(NamedTuple): diff --git a/stdlib/multiprocessing/forkserver.pyi b/stdlib/multiprocessing/forkserver.pyi index df435f00e..9a15f2683 100644 --- a/stdlib/multiprocessing/forkserver.pyi +++ b/stdlib/multiprocessing/forkserver.pyi @@ -24,7 +24,7 @@ def main( def read_signed(fd: int) -> Any: ... def write_signed(fd: int, n: int) -> None: ... -_forkserver: ForkServer = ... +_forkserver: ForkServer ensure_running = _forkserver.ensure_running get_inherited_fds = _forkserver.get_inherited_fds connect_to_new_process = _forkserver.connect_to_new_process diff --git a/stdlib/multiprocessing/resource_tracker.pyi b/stdlib/multiprocessing/resource_tracker.pyi index e2b940796..7f726a00d 100644 --- a/stdlib/multiprocessing/resource_tracker.pyi +++ b/stdlib/multiprocessing/resource_tracker.pyi @@ -9,7 +9,7 @@ class ResourceTracker: def register(self, name: Sized, rtype: Incomplete) -> None: ... def unregister(self, name: Sized, rtype: Incomplete) -> None: ... -_resource_tracker: ResourceTracker = ... +_resource_tracker: ResourceTracker ensure_running = _resource_tracker.ensure_running register = _resource_tracker.register unregister = _resource_tracker.unregister diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index b6f55d624..ed97f1918 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -70,7 +70,7 @@ class HTMLRepr(Repr): def repr_unicode(self, x: AnyStr, level: complex) -> str: ... class HTMLDoc(Doc): - _repr_instance: HTMLRepr = ... + _repr_instance: HTMLRepr repr = _repr_instance.repr escape = _repr_instance.escape def page(self, title: str, contents: str) -> str: ... @@ -154,7 +154,7 @@ class TextRepr(Repr): def repr_instance(self, x: object, level: complex) -> str: ... class TextDoc(Doc): - _repr_instance: TextRepr = ... + _repr_instance: TextRepr repr = _repr_instance.repr def bold(self, text: str) -> str: ... def indent(self, text: str, prefix: str = " ") -> str: ... diff --git a/stdlib/random.pyi b/stdlib/random.pyi index 484987869..5434f2240 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -100,9 +100,7 @@ class SystemRandom(Random): def getstate(self, *args: Any, **kwds: Any) -> NoReturn: ... def setstate(self, *args: Any, **kwds: Any) -> NoReturn: ... -# ----- random function stubs ----- - -_inst: Random = ... +_inst: Random seed = _inst.seed random = _inst.random uniform = _inst.uniform diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 36d2f5bd2..6fc677dcb 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -167,20 +167,14 @@ _T = TypeVar("_T") def overload(func: _F) -> _F: ... -# Unlike the vast majority module-level objects in stub files, -# these `_SpecialForm` objects in typing need the default value `= ...`, -# due to the fact that they are used elswhere in the same file. -# Otherwise, flake8 erroneously flags them as undefined. -# `_SpecialForm` objects in typing.py that are not used elswhere in the same file -# do not need the default value assignment. -Union: _SpecialForm = ... -Generic: _SpecialForm = ... +Union: _SpecialForm +Generic: _SpecialForm # Protocol is only present in 3.8 and later, but mypy needs it unconditionally -Protocol: _SpecialForm = ... -Callable: _SpecialForm = ... -Type: _SpecialForm = ... -NoReturn: _SpecialForm = ... -ClassVar: _SpecialForm = ... +Protocol: _SpecialForm +Callable: _SpecialForm +Type: _SpecialForm +NoReturn: _SpecialForm +ClassVar: _SpecialForm Optional: _SpecialForm Tuple: _SpecialForm @@ -193,7 +187,7 @@ if sys.version_info >= (3, 8): if sys.version_info >= (3, 11): Self: _SpecialForm - Never: _SpecialForm = ... + Never: _SpecialForm Unpack: _SpecialForm Required: _SpecialForm NotRequired: _SpecialForm diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index c3e51a290..1229f6275 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -113,7 +113,7 @@ class _SpecialForm: # typing.Protocol and typing_extensions.Protocol so they can properly # warn users about potential runtime exceptions when using typing.Protocol # on older versions of Python. -Protocol: _SpecialForm = ... +Protocol: _SpecialForm def runtime_checkable(cls: _TC) -> _TC: ... diff --git a/stubs/DateTimeRange/datetimerange/__version__.pyi b/stubs/DateTimeRange/datetimerange/__version__.pyi index 48c3f57fa..37e897a65 100644 --- a/stubs/DateTimeRange/datetimerange/__version__.pyi +++ b/stubs/DateTimeRange/datetimerange/__version__.pyi @@ -1,4 +1,4 @@ -__author__: str = ... +__author__: str __copyright__: str __license__: str __version__: str diff --git a/stubs/colorama/colorama/ansi.pyi b/stubs/colorama/colorama/ansi.pyi index 19e7319b2..3b857496e 100644 --- a/stubs/colorama/colorama/ansi.pyi +++ b/stubs/colorama/colorama/ansi.pyi @@ -20,48 +20,48 @@ class AnsiCursor: # All attributes in the following classes are string in instances and int in the class. # We use str since that is the common case for users. class AnsiFore(AnsiCodes): - BLACK: str = ... - RED: str = ... - GREEN: str = ... - YELLOW: str = ... - BLUE: str = ... - MAGENTA: str = ... - CYAN: str = ... - WHITE: str = ... - RESET: str = ... - LIGHTBLACK_EX: str = ... - LIGHTRED_EX: str = ... - LIGHTGREEN_EX: str = ... - LIGHTYELLOW_EX: str = ... - LIGHTBLUE_EX: str = ... - LIGHTMAGENTA_EX: str = ... - LIGHTCYAN_EX: str = ... - LIGHTWHITE_EX: str = ... + BLACK: str + RED: str + GREEN: str + YELLOW: str + BLUE: str + MAGENTA: str + CYAN: str + WHITE: str + RESET: str + LIGHTBLACK_EX: str + LIGHTRED_EX: str + LIGHTGREEN_EX: str + LIGHTYELLOW_EX: str + LIGHTBLUE_EX: str + LIGHTMAGENTA_EX: str + LIGHTCYAN_EX: str + LIGHTWHITE_EX: str class AnsiBack(AnsiCodes): - BLACK: str = ... - RED: str = ... - GREEN: str = ... - YELLOW: str = ... - BLUE: str = ... - MAGENTA: str = ... - CYAN: str = ... - WHITE: str = ... - RESET: str = ... - LIGHTBLACK_EX: str = ... - LIGHTRED_EX: str = ... - LIGHTGREEN_EX: str = ... - LIGHTYELLOW_EX: str = ... - LIGHTBLUE_EX: str = ... - LIGHTMAGENTA_EX: str = ... - LIGHTCYAN_EX: str = ... - LIGHTWHITE_EX: str = ... + BLACK: str + RED: str + GREEN: str + YELLOW: str + BLUE: str + MAGENTA: str + CYAN: str + WHITE: str + RESET: str + LIGHTBLACK_EX: str + LIGHTRED_EX: str + LIGHTGREEN_EX: str + LIGHTYELLOW_EX: str + LIGHTBLUE_EX: str + LIGHTMAGENTA_EX: str + LIGHTCYAN_EX: str + LIGHTWHITE_EX: str class AnsiStyle(AnsiCodes): - BRIGHT: str = ... - DIM: str = ... - NORMAL: str = ... - RESET_ALL: str = ... + BRIGHT: str + DIM: str + NORMAL: str + RESET_ALL: str Fore: AnsiFore Back: AnsiBack diff --git a/stubs/colorama/colorama/ansitowin32.pyi b/stubs/colorama/colorama/ansitowin32.pyi index c2aade9ee..094a08ee2 100644 --- a/stubs/colorama/colorama/ansitowin32.pyi +++ b/stubs/colorama/colorama/ansitowin32.pyi @@ -3,7 +3,7 @@ from _typeshed import SupportsWrite from collections.abc import Callable, Sequence from re import Pattern from types import TracebackType -from typing import Any, TextIO +from typing import Any, ClassVar, TextIO from typing_extensions import TypeAlias if sys.platform == "win32": @@ -29,15 +29,15 @@ _WinTermCall: TypeAlias = Callable[[int | None, bool, bool], None] _WinTermCallDict: TypeAlias = dict[int, tuple[_WinTermCall] | tuple[_WinTermCall, int] | tuple[_WinTermCall, int, bool]] class AnsiToWin32: - ANSI_CSI_RE: Pattern[str] = ... - ANSI_OSC_RE: Pattern[str] = ... - wrapped: TextIO = ... - autoreset: bool = ... - stream: StreamWrapper = ... - strip: bool = ... - convert: bool = ... - win32_calls: _WinTermCallDict = ... - on_stderr: bool = ... + ANSI_CSI_RE: ClassVar[Pattern[str]] + ANSI_OSC_RE: ClassVar[Pattern[str]] + wrapped: TextIO + autoreset: bool + stream: StreamWrapper + strip: bool + convert: bool + win32_calls: _WinTermCallDict + on_stderr: bool def __init__( self, wrapped: TextIO, convert: bool | None = None, strip: bool | None = None, autoreset: bool = False ) -> None: ... diff --git a/stubs/paramiko/paramiko/kex_gex.pyi b/stubs/paramiko/paramiko/kex_gex.pyi index 57034fe0e..e1c61ce19 100644 --- a/stubs/paramiko/paramiko/kex_gex.pyi +++ b/stubs/paramiko/paramiko/kex_gex.pyi @@ -16,7 +16,7 @@ class KexGex: min_bits: int max_bits: int preferred_bits: int - hash_algo: Callable[[ReadableBuffer], _Hash] = ... + hash_algo: Callable[[ReadableBuffer], _Hash] transport: Transport p: int | None q: int | None @@ -31,4 +31,4 @@ class KexGex: class KexGexSHA256(KexGex): name: str - hash_algo: Callable[[ReadableBuffer], _Hash] = ... + hash_algo: Callable[[ReadableBuffer], _Hash] diff --git a/stubs/pysftp/pysftp/__init__.pyi b/stubs/pysftp/pysftp/__init__.pyi index 88caa944a..e4606f6f7 100644 --- a/stubs/pysftp/pysftp/__init__.pyi +++ b/stubs/pysftp/pysftp/__init__.pyi @@ -25,10 +25,10 @@ from pysftp.helpers import ( ) class CnOpts: - log: bool = ... - compression: bool = ... - ciphers: Sequence[str] | None = ... - hostkeys: paramiko.HostKeys | None = ... + log: bool + compression: bool + ciphers: Sequence[str] | None + hostkeys: paramiko.HostKeys | None def __init__(self, knownhosts: str | None = None) -> None: ... def get_hostkey(self, host: str) -> paramiko.PKey: ... diff --git a/stubs/pysftp/pysftp/exceptions.pyi b/stubs/pysftp/pysftp/exceptions.pyi index 7416456a8..8db14dead 100644 --- a/stubs/pysftp/pysftp/exceptions.pyi +++ b/stubs/pysftp/pysftp/exceptions.pyi @@ -1,9 +1,9 @@ class ConnectionException(Exception): - message: str = ... + message: str def __init__(self, host: str, port: int) -> None: ... class CredentialException(Exception): - message: str = ... + message: str def __init__(self, message: str) -> None: ... class HostKeysException(Exception): ... diff --git a/stubs/simplejson/simplejson/scanner.pyi b/stubs/simplejson/simplejson/scanner.pyi index 42b828a69..66b8d27f8 100644 --- a/stubs/simplejson/simplejson/scanner.pyi +++ b/stubs/simplejson/simplejson/scanner.pyi @@ -1,9 +1,9 @@ class JSONDecodeError(ValueError): - msg: str = ... - doc: str = ... - pos: int = ... - end: int | None = ... - lineno: int = ... - colno: int = ... - endlineno: int | None = ... - endcolno: int | None = ... + msg: str + doc: str + pos: int + end: int | None + lineno: int + colno: int + endlineno: int | None + endcolno: int | None diff --git a/stubs/waitress/@tests/stubtest_allowlist.txt b/stubs/waitress/@tests/stubtest_allowlist.txt index ed036f64b..e9d6b575c 100644 --- a/stubs/waitress/@tests/stubtest_allowlist.txt +++ b/stubs/waitress/@tests/stubtest_allowlist.txt @@ -1,9 +1,6 @@ waitress.adjustments.Adjustments.clear_untrusted_proxy_headers waitress.adjustments.PY2 waitress.adjustments.string_types -waitress.buffers.FileBasedBuffer.__bool__ -waitress.buffers.OverflowableBuffer.__bool__ -waitress.buffers.ReadOnlyFileBasedBuffer.__next__ waitress.channel.HTTPChannel.addr waitress.channel.HTTPChannel.error_task_class waitress.channel.HTTPChannel.parser_class diff --git a/stubs/waitress/waitress/adjustments.pyi b/stubs/waitress/waitress/adjustments.pyi index 433f79564..79cbde1fb 100644 --- a/stubs/waitress/waitress/adjustments.pyi +++ b/stubs/waitress/waitress/adjustments.pyi @@ -22,39 +22,39 @@ class _int_marker(int): ... class _bool_marker: ... class Adjustments: - host: _str_marker = ... - port: _int_marker = ... - listen: list[str] = ... - threads: int = ... - trusted_proxy: str | None = ... - trusted_proxy_count: int | None = ... - trusted_proxy_headers: set[str] = ... - log_untrusted_proxy_headers: bool = ... - clear_untrusted_proxy_headers: _bool_marker | bool = ... - url_scheme: str = ... - url_prefix: str = ... - ident: str = ... - backlog: int = ... - recv_bytes: int = ... - send_bytes: int = ... - outbuf_overflow: int = ... - outbuf_high_watermark: int = ... - inbuf_overflow: int = ... - connection_limit: int = ... - cleanup_interval: int = ... - channel_timeout: int = ... - log_socket_errors: bool = ... - max_request_header_size: int = ... - max_request_body_size: int = ... - expose_tracebacks: bool = ... - unix_socket: str | None = ... - unix_socket_perms: int = ... - socket_options: list[tuple[int, int, int]] = ... - asyncore_loop_timeout: int = ... - asyncore_use_poll: bool = ... - ipv4: bool = ... - ipv6: bool = ... - sockets: list[socket] = ... + host: _str_marker + port: _int_marker + listen: list[str] + threads: int + trusted_proxy: str | None + trusted_proxy_count: int | None + trusted_proxy_headers: set[str] + log_untrusted_proxy_headers: bool + clear_untrusted_proxy_headers: _bool_marker | bool + url_scheme: str + url_prefix: str + ident: str + backlog: int + recv_bytes: int + send_bytes: int + outbuf_overflow: int + outbuf_high_watermark: int + inbuf_overflow: int + connection_limit: int + cleanup_interval: int + channel_timeout: int + log_socket_errors: bool + max_request_header_size: int + max_request_body_size: int + expose_tracebacks: bool + unix_socket: str | None + unix_socket_perms: int + socket_options: list[tuple[int, int, int]] + asyncore_loop_timeout: int + asyncore_use_poll: bool + ipv4: bool + ipv6: bool + sockets: list[socket] def __init__(self, **kw: Any) -> None: ... @classmethod def parse_args(cls, argv: str) -> tuple[dict[str, Any], Any]: ... diff --git a/stubs/waitress/waitress/buffers.pyi b/stubs/waitress/waitress/buffers.pyi index aaa4d4468..1c808d75a 100644 --- a/stubs/waitress/waitress/buffers.pyi +++ b/stubs/waitress/waitress/buffers.pyi @@ -1,17 +1,17 @@ -from collections.abc import Callable from io import BufferedIOBase, BufferedRandom, BytesIO from typing import Any +from typing_extensions import Literal COPY_BYTES: int STRBUF_LIMIT: int class FileBasedBuffer: - remain: int = ... - file: BytesIO = ... + remain: int + file: BytesIO def __init__(self, file: BytesIO, from_buffer: BytesIO | None = None) -> None: ... def __len__(self) -> int: ... def __nonzero__(self) -> bool: ... - __bool__: Callable[[], bool] = ... + def __bool__(self) -> Literal[True]: ... def append(self, s: Any) -> None: ... def get(self, numbytes: int = -1, skip: bool = False) -> bytes: ... def skip(self, numbytes: int, allow_prune: int = 0) -> None: ... @@ -25,31 +25,31 @@ class TempfileBasedBuffer(FileBasedBuffer): def newfile(self) -> BufferedRandom: ... class BytesIOBasedBuffer(FileBasedBuffer): - file: BytesIO = ... + file: BytesIO def __init__(self, from_buffer: BytesIO | None = None) -> None: ... def newfile(self) -> BytesIO: ... class ReadOnlyFileBasedBuffer(FileBasedBuffer): - file: BytesIO = ... - block_size: int = ... + file: BytesIO + block_size: int def __init__(self, file: BytesIO, block_size: int = 32768) -> None: ... - remain: int = ... + remain: int def prepare(self, size: int | None = None) -> int: ... def get(self, numbytes: int = -1, skip: bool = False) -> bytes: ... def __iter__(self) -> ReadOnlyFileBasedBuffer: ... def next(self) -> bytes | None: ... - __next__: Callable[[], bytes | None] = ... + __next__ = next def append(self, s: Any) -> None: ... class OverflowableBuffer: - overflowed: bool = ... - buf: BufferedIOBase | None = ... - strbuf: bytes = ... - overflow: int = ... + overflowed: bool + buf: BufferedIOBase | None + strbuf: bytes + overflow: int def __init__(self, overflow: int) -> None: ... def __len__(self) -> int: ... def __nonzero__(self) -> bool: ... - __bool__: Callable[[], bool] = ... + def __bool__(self) -> bool: ... def append(self, s: bytes) -> None: ... def get(self, numbytes: int = -1, skip: bool = False) -> bytes: ... def skip(self, numbytes: int, allow_prune: bool = False) -> None: ... diff --git a/stubs/waitress/waitress/channel.pyi b/stubs/waitress/waitress/channel.pyi index 1d6d6b09a..05bebc1cd 100644 --- a/stubs/waitress/waitress/channel.pyi +++ b/stubs/waitress/waitress/channel.pyi @@ -13,25 +13,25 @@ from . import wasyncore as wasyncore class ClientDisconnected(Exception): ... class HTTPChannel(wasyncore.dispatcher): - task_class: WSGITask = ... - error_task_class: ErrorTask = ... - parser_class: HTTPRequestParser = ... - request: HTTPRequestParser = ... - last_activity: float = ... - will_close: bool = ... - close_when_flushed: bool = ... - requests: Sequence[HTTPRequestParser] = ... - sent_continue: bool = ... - total_outbufs_len: int = ... - current_outbuf_count: int = ... - server: BaseWSGIServer = ... - adj: Adjustments = ... - outbufs: Sequence[OverflowableBuffer] = ... - creation_time: float = ... - sendbuf_len: int = ... - task_lock: Lock = ... - outbuf_lock: Condition = ... - addr: tuple[str, int] = ... + task_class: WSGITask + error_task_class: ErrorTask + parser_class: HTTPRequestParser + request: HTTPRequestParser + last_activity: float + will_close: bool + close_when_flushed: bool + requests: Sequence[HTTPRequestParser] + sent_continue: bool + total_outbufs_len: int + current_outbuf_count: int + server: BaseWSGIServer + adj: Adjustments + outbufs: Sequence[OverflowableBuffer] + creation_time: float + sendbuf_len: int + task_lock: Lock + outbuf_lock: Condition + addr: tuple[str, int] def __init__( self, server: BaseWSGIServer, sock: socket, addr: str, adj: Adjustments, map: Mapping[int, socket] | None = None ) -> None: ... @@ -40,7 +40,7 @@ class HTTPChannel(wasyncore.dispatcher): def readable(self) -> bool: ... def handle_read(self) -> None: ... def received(self, data: bytes) -> bool: ... - connected: bool = ... + connected: bool def handle_close(self) -> None: ... def add_channel(self, map: Mapping[int, socket] | None = None) -> None: ... def del_channel(self, map: Mapping[int, socket] | None = None) -> None: ... diff --git a/stubs/waitress/waitress/parser.pyi b/stubs/waitress/waitress/parser.pyi index a3867aa44..ec2f57e8b 100644 --- a/stubs/waitress/waitress/parser.pyi +++ b/stubs/waitress/waitress/parser.pyi @@ -11,26 +11,26 @@ class ParsingError(Exception): ... class TransferEncodingNotImplemented(Exception): ... class HTTPRequestParser: - completed: bool = ... - empty: bool = ... - expect_continue: bool = ... - headers_finished: bool = ... - header_plus: bytes = ... - chunked: bool = ... - content_length: int = ... - header_bytes_received: int = ... - body_bytes_received: int = ... - body_rcv: ChunkedReceiver | FixedStreamReceiver | None = ... - version: str = ... - error: Error | None = ... - connection_close: bool = ... - headers: Mapping[str, str] = ... - adj: Adjustments = ... + completed: bool + empty: bool + expect_continue: bool + headers_finished: bool + header_plus: bytes + chunked: bool + content_length: int + header_bytes_received: int + body_bytes_received: int + body_rcv: ChunkedReceiver | FixedStreamReceiver | None + version: str + error: Error | None + connection_close: bool + headers: Mapping[str, str] + adj: Adjustments def __init__(self, adj: Adjustments) -> None: ... def received(self, data: bytes) -> int: ... - first_line: str = ... - command: bytes = ... - url_scheme: str = ... + first_line: str + command: bytes + url_scheme: str def parse_header(self, header_plus: bytes) -> None: ... def get_body_stream(self) -> BytesIO: ... def close(self) -> None: ... diff --git a/stubs/waitress/waitress/proxy_headers.pyi b/stubs/waitress/waitress/proxy_headers.pyi index bc0f20ef6..0861feff5 100644 --- a/stubs/waitress/waitress/proxy_headers.pyi +++ b/stubs/waitress/waitress/proxy_headers.pyi @@ -13,9 +13,9 @@ class Forwarded(NamedTuple): proto: Any class MalformedProxyHeader(Exception): - header: str = ... - reason: str = ... - value: str = ... + header: str + reason: str + value: str def __init__(self, header: str, reason: str, value: str) -> None: ... def proxy_headers_middleware( diff --git a/stubs/waitress/waitress/receiver.pyi b/stubs/waitress/waitress/receiver.pyi index d05ea56b7..bb433405b 100644 --- a/stubs/waitress/waitress/receiver.pyi +++ b/stubs/waitress/waitress/receiver.pyi @@ -4,10 +4,10 @@ from waitress.buffers import OverflowableBuffer from waitress.utilities import BadRequest class FixedStreamReceiver: - completed: bool = ... - error: None = ... - remain: int = ... - buf: OverflowableBuffer = ... + completed: bool + error: None + remain: int + buf: OverflowableBuffer def __init__(self, cl: int, buf: OverflowableBuffer) -> None: ... def __len__(self) -> int: ... def received(self, data: bytes) -> int: ... @@ -15,15 +15,15 @@ class FixedStreamReceiver: def getbuf(self) -> OverflowableBuffer: ... class ChunkedReceiver: - chunk_remainder: int = ... - validate_chunk_end: bool = ... - control_line: bytes = ... - chunk_end: bytes = ... - all_chunks_received: bool = ... - trailer: bytes = ... - completed: bool = ... - error: BadRequest | None = ... - buf: OverflowableBuffer = ... + chunk_remainder: int + validate_chunk_end: bool + control_line: bytes + chunk_end: bytes + all_chunks_received: bool + trailer: bytes + completed: bool + error: BadRequest | None + buf: OverflowableBuffer def __init__(self, buf: OverflowableBuffer) -> None: ... def __len__(self) -> int: ... def received(self, s: bytes) -> int: ... diff --git a/stubs/waitress/waitress/server.pyi b/stubs/waitress/waitress/server.pyi index 1b6546b22..2a6ec7a31 100644 --- a/stubs/waitress/waitress/server.pyi +++ b/stubs/waitress/waitress/server.pyi @@ -19,11 +19,11 @@ def create_server( ) -> MultiSocketServer | BaseWSGIServer: ... class MultiSocketServer: - asyncore: Any = ... - adj: Adjustments = ... - map: Any = ... - effective_listen: Sequence[tuple[str, int]] = ... - task_dispatcher: ThreadedTaskDispatcher = ... + asyncore: Any + adj: Adjustments + map: Any + effective_listen: Sequence[tuple[str, int]] + task_dispatcher: ThreadedTaskDispatcher def __init__( self, map: Incomplete | None = None, @@ -36,19 +36,19 @@ class MultiSocketServer: def close(self) -> None: ... class BaseWSGIServer(wasyncore.dispatcher): - channel_class: HTTPChannel = ... - next_channel_cleanup: int = ... - socketmod: socket = ... - asyncore: Any = ... - sockinfo: tuple[int, int, int, tuple[str, int]] = ... - family: int = ... - socktype: int = ... - application: Any = ... - adj: Adjustments = ... - trigger: int = ... - task_dispatcher: ThreadedTaskDispatcher = ... - server_name: str = ... - active_channels: HTTPChannel = ... + channel_class: HTTPChannel + next_channel_cleanup: int + socketmod: socket + asyncore: Any + sockinfo: tuple[int, int, int, tuple[str, int]] + family: int + socktype: int + application: Any + adj: Adjustments + trigger: int + task_dispatcher: ThreadedTaskDispatcher + server_name: str + active_channels: HTTPChannel def __init__( self, application: Any, @@ -64,7 +64,7 @@ class BaseWSGIServer(wasyncore.dispatcher): def bind_server_socket(self) -> None: ... def get_server_name(self, ip: str) -> str: ... def getsockname(self) -> Any: ... - accepting: bool = ... + accepting: bool def accept_connections(self) -> None: ... def add_task(self, task: Task) -> None: ... def readable(self) -> bool: ... diff --git a/stubs/waitress/waitress/task.pyi b/stubs/waitress/waitress/task.pyi index afb9cd34a..9cd2aeb3f 100644 --- a/stubs/waitress/waitress/task.pyi +++ b/stubs/waitress/waitress/task.pyi @@ -12,15 +12,15 @@ rename_headers: Mapping[str, str] hop_by_hop: frozenset[Any] class ThreadedTaskDispatcher: - stop_count: int = ... - active_count: int = ... - logger: Logger = ... - queue_logger: Logger = ... - threads: set[Any] = ... - queue: deque[Task] = ... - lock: Lock = ... - queue_cv: Condition = ... - thread_exit_cv: Condition = ... + stop_count: int + active_count: int + logger: Logger + queue_logger: Logger + threads: set[Any] + queue: deque[Task] + lock: Lock + queue_cv: Condition + thread_exit_cv: Condition def start_new_thread(self, target: Any, args: Any) -> None: ... def handler_thread(self, thread_no: int) -> None: ... def set_thread_count(self, count: int) -> None: ... @@ -28,21 +28,21 @@ class ThreadedTaskDispatcher: def shutdown(self, cancel_pending: bool = True, timeout: int = 5) -> bool: ... class Task: - close_on_finish: bool = ... - status: str = ... - wrote_header: bool = ... - start_time: int = ... - content_length: int | None = ... - content_bytes_written: int = ... - logged_write_excess: bool = ... - logged_write_no_body: bool = ... - complete: bool = ... - chunked_response: bool = ... - logger: Logger = ... - channel: HTTPChannel = ... - request: Error = ... - response_headers: Sequence[tuple[str, str]] = ... - version: str = ... + close_on_finish: bool + status: str + wrote_header: bool + start_time: int + content_length: int | None + content_bytes_written: int + logged_write_excess: bool + logged_write_no_body: bool + complete: bool + chunked_response: bool + logger: Logger + channel: HTTPChannel + request: Error + response_headers: Sequence[tuple[str, str]] + version: str def __init__(self, channel: HTTPChannel, request: Error) -> None: ... def service(self) -> None: ... @property @@ -54,18 +54,18 @@ class Task: def write(self, data: bytes) -> None: ... class ErrorTask(Task): - complete: bool = ... - status: str = ... - close_on_finish: bool = ... - content_length: int = ... + complete: bool + status: str + close_on_finish: bool + content_length: int def execute(self) -> None: ... class WSGITask(Task): - environ: Incomplete | None = ... - response_headers: Sequence[tuple[str, str]] = ... - complete: bool = ... - status: str = ... - content_length: int = ... - close_on_finish: bool = ... + environ: Incomplete | None + response_headers: Sequence[tuple[str, str]] + complete: bool + status: str + content_length: int + close_on_finish: bool def execute(self) -> None: ... def get_environment(self) -> Any: ... diff --git a/stubs/waitress/waitress/trigger.pyi b/stubs/waitress/waitress/trigger.pyi index 29d785fc3..ae7f82229 100644 --- a/stubs/waitress/waitress/trigger.pyi +++ b/stubs/waitress/waitress/trigger.pyi @@ -7,9 +7,9 @@ from typing_extensions import Literal from waitress import wasyncore as wasyncore class _triggerbase: - kind: str | None = ... - lock: Lock = ... - thunks: Callable[[None], None] = ... + kind: str | None + lock: Lock + thunks: Callable[[None], None] def readable(self) -> Literal[True]: ... def writable(self) -> Literal[False]: ... def handle_connect(self) -> None: ... @@ -20,11 +20,11 @@ class _triggerbase: if sys.platform != "win32": class trigger(_triggerbase, wasyncore.file_dispatcher): - kind: str = ... + kind: str def __init__(self, map: Mapping[str, _triggerbase]) -> None: ... else: class trigger(_triggerbase, wasyncore.dispatcher): - kind: str = ... - trigger: socket = ... + kind: str + trigger: socket def __init__(self, map: Mapping[str, _triggerbase]) -> None: ... diff --git a/stubs/waitress/waitress/utilities.pyi b/stubs/waitress/waitress/utilities.pyi index 621a02aa7..1af73e6db 100644 --- a/stubs/waitress/waitress/utilities.pyi +++ b/stubs/waitress/waitress/utilities.pyi @@ -40,29 +40,29 @@ def undquote(value: str) -> str: ... def cleanup_unix_socket(path: str) -> None: ... class Error: - code: int = ... - reason: str = ... - body: str = ... + code: int + reason: str + body: str def __init__(self, body: str) -> None: ... def to_response(self) -> tuple[str, Sequence[tuple[str, str]], str]: ... def wsgi_response(self, environ: Any, start_response: StartResponse) -> Iterator[str]: ... class BadRequest(Error): - code: int = ... - reason: str = ... + code: int + reason: str class RequestHeaderFieldsTooLarge(BadRequest): - code: int = ... - reason: str = ... + code: int + reason: str class RequestEntityTooLarge(BadRequest): - code: int = ... - reason: str = ... + code: int + reason: str class InternalServerError(Error): - code: int = ... - reason: str = ... + code: int + reason: str class ServerNotImplemented(Error): - code: int = ... - reason: str = ... + code: int + reason: str diff --git a/stubs/waitress/waitress/wasyncore.pyi b/stubs/waitress/waitress/wasyncore.pyi index f2e178dab..2f2e8e3ab 100644 --- a/stubs/waitress/waitress/wasyncore.pyi +++ b/stubs/waitress/waitress/wasyncore.pyi @@ -29,20 +29,20 @@ def loop( def compact_traceback() -> tuple[tuple[str, str, str], BaseException, BaseException, str]: ... class dispatcher: - debug: bool = ... - connected: bool = ... - accepting: bool = ... - connecting: bool = ... - closing: bool = ... - addr: tuple[str, int] | None = ... + debug: bool + connected: bool + accepting: bool + connecting: bool + closing: bool + addr: tuple[str, int] | None ignore_log_types: frozenset[Any] - logger: Logger = ... - compact_traceback: Callable[[], tuple[tuple[str, str, str], BaseException, BaseException, str]] = ... - socket: _Socket | None = ... + logger: Logger + compact_traceback: Callable[[], tuple[tuple[str, str, str], BaseException, BaseException, str]] + socket: _Socket | None def __init__(self, sock: _Socket | None = None, map: Mapping[int, _Socket] | None = None) -> None: ... def add_channel(self, map: Mapping[int, _Socket] | None = None) -> None: ... def del_channel(self, map: Mapping[int, _Socket] | None = None) -> None: ... - family_and_type: tuple[int, int] = ... + family_and_type: tuple[int, int] def create_socket(self, family: int = ..., type: int = ...) -> None: ... def set_socket(self, sock: _Socket, map: Mapping[int, _Socket] | None = None) -> None: ... def set_reuse_addr(self) -> None: ... @@ -71,10 +71,10 @@ class dispatcher: def handle_close(self) -> None: ... class dispatcher_with_send(dispatcher): - out_buffer: bytes = ... + out_buffer: bytes def __init__(self, sock: socket | None = None, map: Mapping[int, socket] | None = None) -> None: ... def initiate_send(self) -> None: ... - handle_write: Callable[[], None] = ... + handle_write: Callable[[], None] def writable(self) -> bool: ... def send(self, data: bytes) -> None: ... # type: ignore[override] @@ -82,19 +82,19 @@ def close_all(map: Mapping[int, socket] | None = None, ignore_all: bool = False) if sys.platform != "win32": class file_wrapper: - fd: BytesIO = ... + fd: BytesIO def __init__(self, fd: BytesIO) -> None: ... def __del__(self) -> None: ... def recv(self, *args: Any) -> bytes: ... def send(self, *args: Any) -> bytes: ... def getsockopt(self, level: int, optname: int, buflen: bool | None = ...) -> int: ... - read: Callable[..., bytes] = ... - write: Callable[..., bytes] = ... + read: Callable[..., bytes] + write: Callable[..., bytes] def close(self) -> None: ... def fileno(self) -> BytesIO: ... class file_dispatcher(dispatcher): - connected: bool = ... + connected: bool def __init__(self, fd: BytesIO, map: Mapping[int, _Socket] | None = ...) -> None: ... - socket: _Socket = ... + socket: _Socket def set_file(self, fd: BytesIO) -> None: ...