Skip to content

Commit 027460f

Browse files
authored
Remove unnecessary ellipsis expressions (#9976)
Ignore flake8 F821 warnings in stub files
1 parent 8df767f commit 027460f

29 files changed

Lines changed: 287 additions & 294 deletions

File tree

.flake8

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,22 @@
2828
# F403 import *' used; unable to detect undefined names
2929
# F405 defined from star imports
3030

31+
# Ignored to workaround pyflakes issues with stub files
32+
# (the bugs this rule catches are caught by our other tests anyway):
33+
# F821 undefined name
34+
3135
[flake8]
3236
extend-ignore = A, D, N8, SIM, RST, TYP, E301, E302, E305, E501
3337
per-file-ignores =
3438
*.py: E203
35-
*.pyi: B, E701, E741, F401, F403, F405, F822
39+
*.pyi: B, E701, E741, F401, F403, F405, F821, F822
3640
# Since typing.pyi defines "overload" this is not recognized by flake8 as typing.overload.
3741
# Unfortunately, flake8 does not allow to "noqa" just a specific error inside the file itself.
3842
# https://github.com/PyCQA/flake8/issues/1079
3943
# F811 redefinition of unused '...'
40-
stdlib/typing.pyi: B, E701, E741, F401, F403, F405, F811, F822
44+
stdlib/typing.pyi: B, E701, E741, F401, F403, F405, F811, F821, F822
4145
# Generated protobuf files include docstrings
42-
*_pb2.pyi: B, E701, E741, F401, F403, F405, F822, Y021, Y026, Y053, Y054
46+
*_pb2.pyi: B, E701, E741, F401, F403, F405, F821, F822, Y021, Y026, Y053, Y054
4347

4448
exclude = .venv*,.git
4549
noqa_require_code = true

stdlib/concurrent/futures/process.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ def _chain_from_iterable_of_lists(iterable: Iterable[MutableSequence[Any]]) -> A
153153
class BrokenProcessPool(BrokenExecutor): ...
154154

155155
class ProcessPoolExecutor(Executor):
156-
_mp_context: BaseContext | None = ...
157-
_initializer: Callable[..., None] | None = ...
158-
_initargs: tuple[Any, ...] = ...
156+
_mp_context: BaseContext | None
157+
_initializer: Callable[..., None] | None
158+
_initargs: tuple[Any, ...]
159159
_executor_manager_thread: _ThreadWakeup
160160
_processes: MutableMapping[int, Process]
161161
_shutdown_thread: bool

stdlib/concurrent/futures/thread.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class ThreadPoolExecutor(Executor):
4444
_broken: bool
4545
_shutdown: bool
4646
_shutdown_lock: Lock
47-
_thread_name_prefix: str | None = ...
48-
_initializer: Callable[..., None] | None = ...
49-
_initargs: tuple[Any, ...] = ...
47+
_thread_name_prefix: str | None
48+
_initializer: Callable[..., None] | None
49+
_initargs: tuple[Any, ...]
5050
_work_queue: queue.SimpleQueue[_WorkItem[Any]]
5151
def __init__(
5252
self,

stdlib/dis.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ _HaveCodeType: TypeAlias = types.MethodType | types.FunctionType | types.CodeTyp
3939

4040
if sys.version_info >= (3, 11):
4141
class Positions(NamedTuple):
42-
lineno: int | None = ...
43-
end_lineno: int | None = ...
44-
col_offset: int | None = ...
45-
end_col_offset: int | None = ...
42+
lineno: int | None = None
43+
end_lineno: int | None = None
44+
col_offset: int | None = None
45+
end_col_offset: int | None = None
4646

4747
if sys.version_info >= (3, 11):
4848
class Instruction(NamedTuple):
@@ -54,7 +54,7 @@ if sys.version_info >= (3, 11):
5454
offset: int
5555
starts_line: int | None
5656
is_jump_target: bool
57-
positions: Positions | None = ...
57+
positions: Positions | None = None
5858

5959
else:
6060
class Instruction(NamedTuple):

stdlib/multiprocessing/forkserver.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def main(
2424
def read_signed(fd: int) -> Any: ...
2525
def write_signed(fd: int, n: int) -> None: ...
2626

27-
_forkserver: ForkServer = ...
27+
_forkserver: ForkServer
2828
ensure_running = _forkserver.ensure_running
2929
get_inherited_fds = _forkserver.get_inherited_fds
3030
connect_to_new_process = _forkserver.connect_to_new_process

stdlib/multiprocessing/resource_tracker.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ResourceTracker:
99
def register(self, name: Sized, rtype: Incomplete) -> None: ...
1010
def unregister(self, name: Sized, rtype: Incomplete) -> None: ...
1111

12-
_resource_tracker: ResourceTracker = ...
12+
_resource_tracker: ResourceTracker
1313
ensure_running = _resource_tracker.ensure_running
1414
register = _resource_tracker.register
1515
unregister = _resource_tracker.unregister

stdlib/pydoc.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class HTMLRepr(Repr):
7070
def repr_unicode(self, x: AnyStr, level: complex) -> str: ...
7171

7272
class HTMLDoc(Doc):
73-
_repr_instance: HTMLRepr = ...
73+
_repr_instance: HTMLRepr
7474
repr = _repr_instance.repr
7575
escape = _repr_instance.escape
7676
def page(self, title: str, contents: str) -> str: ...
@@ -154,7 +154,7 @@ class TextRepr(Repr):
154154
def repr_instance(self, x: object, level: complex) -> str: ...
155155

156156
class TextDoc(Doc):
157-
_repr_instance: TextRepr = ...
157+
_repr_instance: TextRepr
158158
repr = _repr_instance.repr
159159
def bold(self, text: str) -> str: ...
160160
def indent(self, text: str, prefix: str = " ") -> str: ...

stdlib/random.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ class SystemRandom(Random):
100100
def getstate(self, *args: Any, **kwds: Any) -> NoReturn: ...
101101
def setstate(self, *args: Any, **kwds: Any) -> NoReturn: ...
102102

103-
# ----- random function stubs -----
104-
105-
_inst: Random = ...
103+
_inst: Random
106104
seed = _inst.seed
107105
random = _inst.random
108106
uniform = _inst.uniform

stdlib/typing.pyi

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,14 @@ _T = TypeVar("_T")
167167

168168
def overload(func: _F) -> _F: ...
169169

170-
# Unlike the vast majority module-level objects in stub files,
171-
# these `_SpecialForm` objects in typing need the default value `= ...`,
172-
# due to the fact that they are used elswhere in the same file.
173-
# Otherwise, flake8 erroneously flags them as undefined.
174-
# `_SpecialForm` objects in typing.py that are not used elswhere in the same file
175-
# do not need the default value assignment.
176-
Union: _SpecialForm = ...
177-
Generic: _SpecialForm = ...
170+
Union: _SpecialForm
171+
Generic: _SpecialForm
178172
# Protocol is only present in 3.8 and later, but mypy needs it unconditionally
179-
Protocol: _SpecialForm = ...
180-
Callable: _SpecialForm = ...
181-
Type: _SpecialForm = ...
182-
NoReturn: _SpecialForm = ...
183-
ClassVar: _SpecialForm = ...
173+
Protocol: _SpecialForm
174+
Callable: _SpecialForm
175+
Type: _SpecialForm
176+
NoReturn: _SpecialForm
177+
ClassVar: _SpecialForm
184178

185179
Optional: _SpecialForm
186180
Tuple: _SpecialForm
@@ -193,7 +187,7 @@ if sys.version_info >= (3, 8):
193187

194188
if sys.version_info >= (3, 11):
195189
Self: _SpecialForm
196-
Never: _SpecialForm = ...
190+
Never: _SpecialForm
197191
Unpack: _SpecialForm
198192
Required: _SpecialForm
199193
NotRequired: _SpecialForm

stdlib/typing_extensions.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class _SpecialForm:
113113
# typing.Protocol and typing_extensions.Protocol so they can properly
114114
# warn users about potential runtime exceptions when using typing.Protocol
115115
# on older versions of Python.
116-
Protocol: _SpecialForm = ...
116+
Protocol: _SpecialForm
117117

118118
def runtime_checkable(cls: _TC) -> _TC: ...
119119

0 commit comments

Comments
 (0)