Remove unnecessary ellipsis expressions (#9976)

Ignore flake8 F821 warnings in stub files
This commit is contained in:
Sebastian Rittau
2023-03-29 13:28:06 +02:00
committed by GitHub
parent 8df767f163
commit 027460f11a
29 changed files with 287 additions and 294 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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):

View File

@@ -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

View File

@@ -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

View File

@@ -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: ...

View File

@@ -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

View File

@@ -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

View File

@@ -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: ...