Add @disjoint_base decorator in the stdlib (#14599)

And fix some other new stubtest finds.
This commit is contained in:
Jelle Zijlstra
2025-08-24 07:27:14 -07:00
committed by GitHub
parent 2565f34946
commit e8ba06f710
55 changed files with 701 additions and 307 deletions
+2 -18
View File
@@ -4,15 +4,14 @@
# Please keep sorted alphabetically
collections\.ChainMap\.fromkeys # https://github.com/python/mypy/issues/17023
http.client.HTTPConnection.response_class # the actual type at runtime is abc.ABCMeta
importlib.abc.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined for backwards compatibility
importlib.abc.MetaPathFinder.find_spec # Not defined on the actual class, but expected to exist.
importlib.abc.PathEntryFinder.find_spec # Not defined on the actual class, but expected to exist.
tkinter.simpledialog.[A-Z_]+
tkinter.simpledialog.TclVersion
tkinter.simpledialog.TkVersion
tkinter.Text.count # stubtest somehow thinks that index1 parameter has a default value, but it doesn't in any of the overloads
builtins.tuple # should have @disjoint_base but hits pyright issue
tarfile.TarInfo.__slots__ # it's a big dictionary at runtime and the dictionary values are a bit long
# ===============================================================
@@ -201,7 +200,6 @@ _markupbase.ParserBase.parse_marked_section
_pydecimal.* # See comments in file
_typeshed.* # Utility types for typeshed, doesn't exist at runtime
argparse.ArgumentParser.__init__ # stubtest doesn't recognise the runtime default (a class) as being compatible with a callback protocol (the stub annotation)
argparse.Namespace.__getattr__ # The whole point of this class is its attributes are dynamic
# Runtime AST node runtime constructor behaviour is too loose.
@@ -218,8 +216,6 @@ argparse.Namespace.__setattr__ # should allow setting any attribute
ast.ImportFrom.level # None on the class, but never None on instances
ast.NodeVisitor.visit_\w+ # Methods are discovered dynamically, see #3796
_?asyncio.Future.__init__ # Usually initialized from c object
asyncio.futures.Future.__init__ # Usually initialized from c object
# Condition functions are exported in __init__
asyncio.Condition.acquire
@@ -230,7 +226,6 @@ asyncio.locks.Condition.locked
asyncio.locks.Condition.release
builtins.memoryview.__contains__ # C type that implements __getitem__
builtins.object.__init__ # default C signature is incorrect
builtins.reveal_locals # Builtins that type checkers pretends exist
builtins.reveal_type # Builtins that type checkers pretends exist
builtins.type.__dict__ # read-only but not actually a property; stubtest thinks it's a mutable attribute.
@@ -260,8 +255,6 @@ configparser.SectionProxy.getint # SectionProxy get functions are set in __init
contextlib.AbstractAsyncContextManager.__class_getitem__
contextlib.AbstractContextManager.__class_getitem__
_?contextvars.Context.__init__ # C signature is broader than what is actually accepted
copy.PyStringMap # defined only in Jython
# The Dialect properties are initialized as None in Dialect but their values are enforced in _Dialect
@@ -329,9 +322,6 @@ importlib.machinery.ExtensionFileLoader.get_filename
inspect.Parameter.__init__
inspect.Signature.__init__
inspect.Parameter.empty # set as private marker _empty
inspect.Signature.empty # set as private marker _empty
logging.LogRecord.__setattr__ # doesn't exist, but makes things easy if we pretend it does
# Iterable classes that don't define __iter__ at runtime (usually iterable via __getitem__)
@@ -377,11 +367,6 @@ multiprocessing.queues.JoinableQueue.__init__
multiprocessing.queues.Queue.__init__
multiprocessing.queues.SimpleQueue.__init__
# alias for a class defined elsewhere,
# mypy infers the variable has type `(*args) -> ForkingPickler`
# but stubtest infers the runtime type as <class ForkingPickler>
multiprocessing.reduction.AbstractReducer.ForkingPickler
# These methods are dynamically created after object initialization,
# copied from a wrapped lock object. Stubtest doesn't think they exist
# because of that.
@@ -406,7 +391,6 @@ os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all Pat
pickle._Pickler\..* # Best effort typing for undocumented internals
pickle._Unpickler\..* # Best effort typing for undocumented internals
_?queue.SimpleQueue.__init__ # C signature is broader than what is actually accepted
shutil.rmtree # function with attributes, which we approximate with a callable protocol
socketserver.BaseServer.get_request # Not implemented, but expected to exist on subclasses.
ssl.PROTOCOL_SSLv2 # Depends on the existence and flags of SSL
@@ -43,7 +43,6 @@ curses.LINES # Initialized only after initscr call
curses.has_key # stubtest gets confused because this is both a module and a function in curses
multiprocessing.popen_spawn_win32 # exists on Darwin but fails to import
readline.append_history_file # Only available if compiled with GNU readline, not editline
select.kqueue.__init__ # default C signature is wrong
select.poll # Actually a function; we have a class so it can be used as a type
# Some of these exist on non-windows, but they are useless and this is not intended
+2 -1
View File
@@ -55,6 +55,8 @@ asyncio.locks.Lock.__init__
asyncio.locks.Semaphore.__init__
asyncio.queues.Queue.__init__
_random.Random.__init__ # Issues with __new__/__init__ correspondence
bdb.Breakpoint.clearBreakpoints # Exists at runtime, but missing from stubs
@@ -100,7 +102,6 @@ typing_extensions.Sentinel.__call__
# <= 3.11
# =======
_?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
enum.Enum._generate_next_value_
importlib.abc.Finder.find_module
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified
@@ -68,7 +68,6 @@ importlib.metadata._meta.SimplePath.__truediv__ # Runtime definition of protoco
# <= 3.11
# =======
_?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
enum.Enum._generate_next_value_
importlib.abc.Finder.find_module
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified
@@ -54,7 +54,6 @@ typing_extensions.Sentinel.__call__
# <= 3.11
# =======
_?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
enum.Enum._generate_next_value_
importlib.abc.Finder.find_module
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified
@@ -2,10 +2,6 @@
# TODO: Allowlist entries that should be fixed
# ============================================
# alias for a class defined elsewhere,
# mypy infers the variable has type `(*args) -> DupHandle` but stubtest infers the runtime type as <class DupHandle>
multiprocessing.reduction.AbstractReducer.DupHandle
# Exists at runtime, but missing from stubs
_winapi.CreateFileMapping
_winapi.MapViewOfFile