Skip to content

Commit f26ad20

Browse files
authored
Remove Python3.8 stubtest allowlists (#13389)
Consolidate remaining allowlists
1 parent 10ebc99 commit f26ad20

File tree

10 files changed

+32
-632
lines changed

10 files changed

+32
-632
lines changed

stdlib/@tests/stubtest_allowlists/common.txt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ idlelib
4545
# Module members that exist at runtime, but are deliberately missing from stubs
4646
# =============================================================================
4747

48+
_collections_abc.AsyncIterable.__class_getitem__
49+
_collections_abc.Awaitable.__class_getitem__
50+
_collections_abc.Container.__class_getitem__
51+
_collections_abc.Iterable.__class_getitem__
52+
_collections_abc.MappingView.__class_getitem__
53+
4854
_collections_abc.Mapping.__reversed__ # set to None at runtime for a better error message
4955

5056
# Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414.
@@ -211,8 +217,11 @@ _?ast.excepthandler.__init__
211217
_?ast.expr.__init__
212218
_?ast.stmt.__init__
213219

220+
_ast.ImportFrom.level # None on the class, but never None on instances
221+
214222
ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
215223
ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
224+
ast.ImportFrom.level # None on the class, but never None on instances
216225
ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
217226
ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
218227
ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
@@ -253,7 +262,14 @@ configparser.SectionProxy.__getattr__ # SectionProxy can have arbitrary attribu
253262
configparser.SectionProxy.getboolean # SectionProxy get functions are set in __init__
254263
configparser.SectionProxy.getfloat # SectionProxy get functions are set in __init__
255264
configparser.SectionProxy.getint # SectionProxy get functions are set in __init__
265+
266+
# Treated an alias of a typing class in the stubs,
267+
# they are generic to type checkers anyway.
268+
contextlib.AbstractAsyncContextManager.__class_getitem__
269+
contextlib.AbstractContextManager.__class_getitem__
270+
256271
_?contextvars.Context.__init__ # C signature is broader than what is actually accepted
272+
257273
copy.PyStringMap # defined only in Jython
258274

259275
# The Dialect properties are initialized as None in Dialect but their values are enforced in _Dialect
@@ -296,7 +312,10 @@ email.policy.EmailPolicy.message_factory # "type" at runtime, but protocol in s
296312
enum.auto.__or__ # enum.auto is magic, see comments
297313
enum.auto.__and__ # enum.auto is magic, see comments
298314
enum.auto.__xor__ # enum.auto is magic, see comments
315+
316+
functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
299317
functools.cached_property.__set__ # doesn't exist, but cached_property is settable by another mechanism
318+
300319
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
301320
hmac.new # Raises TypeError if optional argument digestmod is not provided
302321
http.HTTPStatus.description # set in __new__; work-around for enum wierdness
@@ -310,6 +329,7 @@ importlib._bootstrap_external.FileLoader.get_resource_reader
310329
importlib._bootstrap_external.FileLoader.load_module
311330
importlib.abc.FileLoader.get_filename
312331
importlib.abc.FileLoader.load_module
332+
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
313333
importlib.machinery.ExtensionFileLoader.get_filename
314334

315335
# We can't distinguish not having a default value from having a default value of inspect.Parameter.empty
@@ -377,13 +397,16 @@ multiprocessing.synchronize.SemLock.release
377397

378398
numbers.Number.__hash__ # typeshed marks this as abstract but code just sets this as None
379399
optparse.Values.__getattr__ # Some attributes are set in __init__ using setattr
400+
380401
os._wrap_close.read # Methods that come from __getattr__() at runtime
381402
os._wrap_close.readable # Methods that come from __getattr__() at runtime
382403
os._wrap_close.readline # Methods that come from __getattr__() at runtime
383404
os._wrap_close.readlines # Methods that come from __getattr__() at runtime
384405
os._wrap_close.writable # Methods that come from __getattr__() at runtime
385406
os._wrap_close.write # Methods that come from __getattr__() at runtime
386407
os._wrap_close.writelines # Methods that come from __getattr__() at runtime
408+
os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all PathLike classes to implement class_getitem
409+
387410
pickle._Pickler\..* # Best effort typing for undocumented internals
388411
pickle._Unpickler\..* # Best effort typing for undocumented internals
389412
_?queue.SimpleQueue.__init__ # C signature is broader than what is actually accepted
@@ -433,6 +456,11 @@ traceback.TracebackException.from_exception # explicitly expanding arguments go
433456
turtle.ScrolledCanvas.find_all # Dynamically created, has unnecessary *args
434457
turtle.ScrolledCanvas.select_clear # Dynamically created, has unnecessary *args
435458
turtle.ScrolledCanvas.select_item # Dynamically created, has unnecessary *args
459+
460+
types.GenericAlias.__call__ # Would be complicated to fix properly, Any could silence problems. #6392
461+
types.GenericAlias.__getattr__
462+
types.GenericAlias.__mro_entries__
463+
436464
typing.type_check_only # typing decorator that is not available at runtime
437465

438466
# Details of runtime definition don't need to be in stubs
@@ -468,14 +496,14 @@ typing(_extensions)?\.Match
468496
typing(_extensions)?\.MutableMapping
469497
typing(_extensions)?\.MutableSequence
470498
typing(_extensions)?\.MutableSet
499+
typing(_extensions)?\.NamedTuple
471500
typing(_extensions)?\.Pattern
472501
typing(_extensions)?\.Reversible
473502
typing(_extensions)?\.Sequence
474503
typing(_extensions)?\.Sized
475504
typing(_extensions)?\.ValuesView
476505
typing_extensions\.Final
477506
typing_extensions\.LiteralString
478-
typing_extensions\.NamedTuple
479507

480508
typing._SpecialForm.__call__ # Typing-related weirdness
481509
typing._SpecialForm.__init__ # Typing-related weirdness
@@ -512,11 +540,14 @@ urllib.response.addbase.write # Methods that come from __getattr__() at runtime
512540
urllib.response.addbase.writelines # Methods that come from __getattr__() at runtime
513541
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified
514542
unittest.mock.patch # function with attributes, which we approximate with a callable class
543+
515544
_?weakref\.CallableProxyType\.__getattr__ # Should have all attributes of proxy
516545
_?weakref\.(ref|ReferenceType)\.__init__ # C implementation has incorrect signature
517546
_?weakref\.(ref|ReferenceType)\.__call__ # C function default annotation is wrong
518547
_?weakref\.ProxyType\.__getattr__ # Should have all attributes of proxy
548+
_?weakref\.ProxyType\.__reversed__ # Doesn't really exist
519549
weakref.WeakValueDictionary.setdefault # has a default value for the "default" argument, but always errors out if no value is supplied for the parameter by the user
550+
520551
webbrowser.UnixBrowser.remote_action # Always overridden in inheriting class
521552
webbrowser.UnixBrowser.remote_action_newtab # Always overridden in inheriting class
522553
webbrowser.UnixBrowser.remote_action_newwin # Always overridden in inheriting class

stdlib/@tests/stubtest_allowlists/darwin-py38.txt

Lines changed: 0 additions & 51 deletions
This file was deleted.

stdlib/@tests/stubtest_allowlists/linux-py38.txt

Lines changed: 0 additions & 36 deletions
This file was deleted.

stdlib/@tests/stubtest_allowlists/py310.txt

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,6 @@ importlib.metadata._meta.SimplePath.__truediv__ # Runtime definition of protoco
7272
# ===================================
7373

7474

75-
# ======
76-
# >= 3.9
77-
# ======
78-
79-
# Exists at runtime, but missing from stubs
80-
_collections_abc.AsyncIterable.__class_getitem__
81-
_collections_abc.Awaitable.__class_getitem__
82-
_collections_abc.Container.__class_getitem__
83-
_collections_abc.Iterable.__class_getitem__
84-
_collections_abc.MappingView.__class_getitem__
85-
86-
8775
# ===========
8876
# 3.9 to 3.10
8977
# ===========
@@ -181,29 +169,6 @@ unittest.TestCase.__init_subclass__ # Runtime has *args, **kwargs, but will err
181169
unittest.case.TestCase.__init_subclass__ # Runtime has *args, **kwargs, but will error if any are supplied
182170

183171

184-
# ============================================================
185-
# Allowlist entries that cannot or should not be fixed; >= 3.9
186-
# ============================================================
187-
188-
_ast.ImportFrom.level # None on the class, but never None on instances
189-
_weakref.ProxyType.__reversed__ # Doesn't really exist
190-
ast.ImportFrom.level # None on the class, but never None on instances
191-
192-
# Treated an alias of a typing class in the stubs,
193-
# they are generic to type checkers anyway.
194-
contextlib.AbstractAsyncContextManager.__class_getitem__
195-
contextlib.AbstractContextManager.__class_getitem__
196-
197-
functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
198-
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
199-
os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all PathLike classes to implement class_getitem
200-
types.GenericAlias.__call__ # Would be complicated to fix properly, Any could silence problems. #6392
201-
types.GenericAlias.__getattr__
202-
types.GenericAlias.__mro_entries__
203-
typing\.NamedTuple # Super-special typing primitive
204-
weakref.ProxyType.__reversed__ # Doesn't really exist
205-
206-
207172
# ===============================================================
208173
# Allowlist entries that cannot or should not be fixed; 3.10 only
209174
# ===============================================================

stdlib/@tests/stubtest_allowlists/py311.txt

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,6 @@ typing(_extensions)?\.IO\.write
6060
typing(_extensions)?\.IO\.writelines
6161

6262

63-
# ======
64-
# >= 3.9
65-
# ======
66-
67-
# Exists at runtime, but missing from stubs
68-
_collections_abc.AsyncIterable.__class_getitem__
69-
_collections_abc.Awaitable.__class_getitem__
70-
_collections_abc.Container.__class_getitem__
71-
_collections_abc.Iterable.__class_getitem__
72-
_collections_abc.MappingView.__class_getitem__
73-
74-
7563
# ============
7664
# 3.10 to 3.11
7765
# ============
@@ -162,29 +150,6 @@ unittest.TestCase.__init_subclass__ # Runtime has *args, **kwargs, but will err
162150
unittest.case.TestCase.__init_subclass__ # Runtime has *args, **kwargs, but will error if any are supplied
163151

164152

165-
# ============================================================
166-
# Allowlist entries that cannot or should not be fixed; >= 3.9
167-
# ============================================================
168-
169-
_ast.ImportFrom.level # None on the class, but never None on instances
170-
_weakref.ProxyType.__reversed__ # Doesn't really exist
171-
ast.ImportFrom.level # None on the class, but never None on instances
172-
173-
# Treated an alias of a typing class in the stubs,
174-
# they are generic to type checkers anyway.
175-
contextlib.AbstractAsyncContextManager.__class_getitem__
176-
contextlib.AbstractContextManager.__class_getitem__
177-
178-
functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
179-
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
180-
os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all PathLike classes to implement class_getitem
181-
types.GenericAlias.__call__ # Would be complicated to fix properly, Any could silence problems. #6392
182-
types.GenericAlias.__getattr__
183-
types.GenericAlias.__mro_entries__
184-
typing\.NamedTuple # Super-special typing primitive
185-
weakref.ProxyType.__reversed__ # Doesn't really exist
186-
187-
188153
# ===============================================================
189154
# Allowlist entries that cannot or should not be fixed; 3.11 only
190155
# ===============================================================

stdlib/@tests/stubtest_allowlists/py312.txt

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ typing(_extensions)?\.IO\.write
5959
typing(_extensions)?\.IO\.writelines
6060

6161

62-
# ======
63-
# >= 3.9
64-
# ======
65-
66-
# Exists at runtime, but missing from stubs
67-
_collections_abc.AsyncIterable.__class_getitem__
68-
_collections_abc.Awaitable.__class_getitem__
69-
_collections_abc.Container.__class_getitem__
70-
_collections_abc.Iterable.__class_getitem__
71-
_collections_abc.MappingView.__class_getitem__
72-
73-
7462
# =======
7563
# <= 3.12
7664
# =======
@@ -175,29 +163,6 @@ unittest.TestCase.__init_subclass__ # Runtime has *args, **kwargs, but will err
175163
unittest.case.TestCase.__init_subclass__ # Runtime has *args, **kwargs, but will error if any are supplied
176164

177165

178-
# ============================================================
179-
# Allowlist entries that cannot or should not be fixed; >= 3.9
180-
# ============================================================
181-
182-
_ast.ImportFrom.level # None on the class, but never None on instances
183-
_weakref.ProxyType.__reversed__ # Doesn't really exist
184-
ast.ImportFrom.level # None on the class, but never None on instances
185-
186-
# Treated an alias of a typing class in the stubs,
187-
# they are generic to type checkers anyway.
188-
contextlib.AbstractAsyncContextManager.__class_getitem__
189-
contextlib.AbstractContextManager.__class_getitem__
190-
191-
functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
192-
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
193-
os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all PathLike classes to implement class_getitem
194-
types.GenericAlias.__call__ # Would be complicated to fix properly, Any could silence problems. #6392
195-
types.GenericAlias.__getattr__
196-
types.GenericAlias.__mro_entries__
197-
typing\.NamedTuple # Super-special typing primitive
198-
weakref.ProxyType.__reversed__ # Doesn't really exist
199-
200-
201166
# ===============================================================
202167
# Allowlist entries that cannot or should not be fixed; 3.12 only
203168
# ===============================================================

0 commit comments

Comments
 (0)