From 8b29478b231b9a033f0db46a94662c15201b52b8 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 4 Mar 2022 13:27:01 +0000 Subject: [PATCH 1/5] Use latest stubtest in CI --- .github/workflows/stubtest.yml | 2 +- .github/workflows/tests.yml | 2 +- tests/stubtest_allowlists/py310.txt | 21 ++++++++++++++++++++ tests/stubtest_allowlists/py3_common.txt | 25 +++++++++++++++++++++++- tests/stubtest_third_party.py | 2 +- 5 files changed, 48 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 708692c62a75..d092a96329cd 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -39,7 +39,7 @@ jobs: # - get_mypy_req in tests/stubtest_third_party.py # - stubtest-stdlib in .github/workflows/stubtest.yml # - stubtest-stdlib in .github/workflows/tests.yml - run: pip install $(grep tomli== requirements-tests.txt) git+git://github.com/python/mypy@080bb0e04e9d5c4d2513621d1fb62f1d61a573e9 + run: pip install $(grep tomli== requirements-tests.txt) git+git://github.com/python/mypy@a562f0aac287b1069a8267b3812fb6813eaefec3 - name: Run stubtest run: python tests/stubtest_stdlib.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a6c72dc9f93f..08ee9405ee62 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -114,7 +114,7 @@ jobs: # - get_mypy_req in tests/stubtest_third_party.py # - stubtest-stdlib in .github/workflows/stubtest.yml # - stubtest-stdlib in .github/workflows/tests.yml - run: pip install $(grep tomli== requirements-tests.txt) git+git://github.com/python/mypy@080bb0e04e9d5c4d2513621d1fb62f1d61a573e9 + run: pip install $(grep tomli== requirements-tests.txt) git+git://github.com/python/mypy@a562f0aac287b1069a8267b3812fb6813eaefec3 - name: Run stubtest run: python tests/stubtest_stdlib.py diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index 4c77a02746dc..6039b948765c 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -16,6 +16,25 @@ _collections_abc.MutableMapping.__setitem__ _collections_abc.MutableMapping.pop _collections_abc.MutableMapping.setdefault +# Many positional-only differences with KeysView/ItemsView +_collections_abc.dict_keys.__.*__ +_collections_abc.dict_items.__.*__ + +# Pos-only differences with object.__setattr__/object.__delattr__ +# Adding these to the stub has bad consequences (see #7385, #7347) +enum.EnumMeta.__setattr__ +enum.EnumMeta.__delattr__ +uuid.UUID.__setattr__ + +# Pos-only differences with the normal NamedTuple __getitem__ +platform.uname_result.__getitem__ + +# mypy does not autogenerate __eq__ methods for dataclasses, +# so wrongly infers that these have positional-only parameters. +# https://github.com/python/mypy/issues/12186 +pstats.FunctionProfile.__eq__ +pstats.StatsProfile.__eq__ + # typing.IO uses positional-or-keyword arguments, but in the stubs we prefer # to mark these as positional-only for compatibility with existing sub-classes. typing.BinaryIO.write @@ -112,6 +131,8 @@ _collections_abc.Coroutine.send _collections_abc.Coroutine.throw _collections_abc.Generator.send _collections_abc.Generator.throw +_collections_abc.Mapping.__eq__ +_collections_abc.Set.__eq__ contextlib.AbstractAsyncContextManager.__aexit__ contextlib.AbstractContextManager.__exit__ diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index e4fe05c80536..7e61d8416c0c 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -13,8 +13,14 @@ _collections_abc.Generator.gi_code _collections_abc.Generator.gi_frame _collections_abc.Generator.gi_running _collections_abc.Generator.gi_yieldfrom +_collections_abc.Mapping.__reversed__ # set to None at runtime for a better error message _collections_abc.Mapping.get # Adding None to the Union messed up mypy _collections_abc.Sequence.index # Supporting None in end is not mandatory +# Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414. +_collections_abc.Set.__rand__ +_collections_abc.Set.__ror__ +_collections_abc.Set.__rsub__ +_collections_abc.Set.__rxor__ _csv.Dialect.__init__ # C __init__ signature is inaccurate _socket.* _threading_local.local.__new__ @@ -27,6 +33,7 @@ argparse.Namespace.__getattr__ # The whole point of this class is its attribute asynchat.async_chat.encoding # Removal planned for 3.12, can add if someone needs this asynchat.async_chat.use_encoding # Removal planned for 3.12, can add if someone needs this asynchat.find_prefix_at_end # Removal planned for 3.12, can add if someone needs this +asynchat.__warningregistry__ # Removal planned for 3.12, can add if someone needs this asyncio.BaseEventLoop.subprocess_exec # BaseEventLoop adds several parameters and stubtest fails on the difference if we add them # Condition functions are exported in __init__ asyncio.Condition.acquire @@ -240,14 +247,24 @@ xml.parsers.expat.expat_CAPI # Allowlist entries that cannot or should not be fixed # ========== _pydecimal.* # See comments in file +_weakref.ProxyType.__bytes__ # Doesn't really exist +_weakref.ProxyType.__reversed__ # Doesn't really exist ast.NodeVisitor.visit_\w+ # Methods are discovered dynamically, see #3796 # Weird special builtins that are typed as functions, but aren't functions builtins.copyright builtins.credits builtins.exit +builtins.float.__getformat__ # Internal method for CPython test suite +builtins.float.__set_format__ # Internal method for CPython test suite builtins.help builtins.license +builtins.property.__set_name__ # Doesn't actually exist builtins.quit +# These super() dunders don't seem to be particularly useful, +# and having them pop up on autocomplete suggestions would be annoying +builtins.super.__self__ +builtins.super.__self_class__ +builtins.super.__thisclass__ # GetSetDescriptor that always raises AttributeError builtins.OSError.characters_written # Aliases for OSError @@ -290,6 +307,8 @@ sys.tracebacklimit codecs.StreamReaderWriter.\w+ codecs.StreamRecoder.\w+ urllib.response.addbase.\w+ +weakref.ProxyType.__bytes__ # Doesn't actually exist +weakref.ProxyType.__reversed__ # Doesn't actually exist # Dynamically created, has unnecessary *args turtle.ScrolledCanvas.find_all @@ -453,6 +472,7 @@ email.contentmanager.get_text_content email.contentmanager.set_bytes_content email.contentmanager.set_message_content email.contentmanager.set_text_content +functools.partial.__vectorcalloffset__ pipes.Template.makepipeline pipes.Template.open_r pipes.Template.open_w @@ -514,6 +534,7 @@ distutils.cmd.Command.dump_options distutils.cmd.Command.ensure_finalized distutils.command.bdist distutils.command.bdist_rpm.DEBUG +distutils.command.build_ext.__warningregistry__ distutils.command.build_ext.USER_BASE distutils.command.build_scripts.ST_MODE distutils.command.install.* @@ -668,7 +689,6 @@ pkgutil.ImpLoader.source # ========== # Exists at runtime, but missing from stubs # ========== -__main__.\w+ _json.encode_basestring _thread.LockType.acquire_lock _thread.LockType.locked_lock @@ -690,6 +710,7 @@ ctypes.ARRAY ctypes.SetPointerType ctypes.c_voidp ctypes.util.test +dbm.dumb._Database.__contains__ importlib.abc.Finder.find_module lib2to3.pgen2.grammar.Grammar.loads logging.config.BaseConfigurator @@ -748,3 +769,5 @@ tkinter.tix.ScrolledText tkinter.tix.ScrolledWindow tkinter.tix.Shell turtle.TNavigator.speed +types.GenericAlias.__mro_entries__ +typing._SpecialForm.__mro_entries__ diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index 3c858a056ae3..7fce6d856a42 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -22,7 +22,7 @@ def get_mypy_req(): # - get_mypy_req in tests/stubtest_third_party.py # - stubtest-stdlib in .github/workflows/stubtest.yml # - stubtest-stdlib in .github/workflows/tests.yml - return "git+git://github.com/python/mypy@080bb0e04e9d5c4d2513621d1fb62f1d61a573e9" + return "git+git://github.com/python/mypy@a562f0aac287b1069a8267b3812fb6813eaefec3" with open("requirements-tests.txt") as f: return next(line.strip() for line in f if "mypy" in line) From b26a7456800924480f6197a9d9902c2da1f49084 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 4 Mar 2022 13:46:56 +0000 Subject: [PATCH 2/5] Allow --- tests/stubtest_allowlists/py310.txt | 10 ++++++++++ tests/stubtest_allowlists/py36.txt | 2 ++ tests/stubtest_allowlists/py37.txt | 1 + tests/stubtest_allowlists/py38.txt | 1 + tests/stubtest_allowlists/py39.txt | 5 +++++ tests/stubtest_allowlists/py3_common.txt | 9 --------- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index 6039b948765c..5ab0733acf52 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -47,6 +47,7 @@ typing.IO.truncate typing.IO.write typing.IO.writelines +_weakref.ProxyType.__reversed__ # Doesn't really exist ast.Bytes.__new__ ast.Ellipsis.__new__ ast.ExtSlice.__new__ @@ -60,6 +61,8 @@ asyncio.Future._callbacks # Usually initialized from c object asyncio.futures.Future.__init__ # Usually initialized from c object asyncio.futures.Future._callbacks # Usually initialized from c object builtins.dict.get +builtins.float.__set_format__ # Internal method for CPython test suite +builtins.property.__set_name__ # Doesn't actually exist contextvars.Context.__init__ # Default C __init__ signature is wrong contextlib.AbstractAsyncContextManager.__class_getitem__ contextlib.AbstractContextManager.__class_getitem__ @@ -97,9 +100,11 @@ sys.UnraisableHookArgs # Not exported from sys types.ClassMethodDescriptorType.__get__ types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime types.GenericAlias.__getattr__ +types.GenericAlias.__mro_entries__ types.GenericAlias.__call__ # Would be complicated to fix properly, Any could silence problems. #6392 types.MethodDescriptorType.__get__ types.WrapperDescriptorType.__get__ +typing._SpecialForm.__mro_entries__ typing.ForwardRef._evaluate typing.SupportsAbs.__init__ typing.SupportsBytes.__init__ @@ -119,6 +124,7 @@ typing._TypedDict.pop typing._TypedDict.setdefault typing._TypedDict.update typing._TypedDict.values +weakref.ProxyType.__reversed__ # Doesn't really exist weakref.WeakValueDictionary.update xml.etree.ElementTree.XMLParser.__init__ # Defined in C so has general signature xml.etree.cElementTree.XMLParser.__init__ # Defined in C so has general signature @@ -167,13 +173,17 @@ _csv.Writer _imp.source_hash ast.Tuple.dims ast.main +asynchat.__warningregistry__ # Removal planned for 3.12, can add if someone needs this asyncio.AbstractEventLoop.connect_accepted_socket asyncio.events.AbstractEventLoop.connect_accepted_socket bdb.Breakpoint.clearBreakpoints +dbm.dumb._Database.__contains__ +distutils.command.build_ext.__warningregistry__ distutils.dist.DistributionMetadata.set_classifiers distutils.dist.DistributionMetadata.set_keywords distutils.dist.DistributionMetadata.set_platforms distutils.util.get_host_platform +functools.partial.__vectorcalloffset__ # undocumented implementation detail multiprocessing.managers.SharedMemoryServer.create multiprocessing.managers.SharedMemoryServer.list_segments multiprocessing.managers.SharedMemoryServer.public diff --git a/tests/stubtest_allowlists/py36.txt b/tests/stubtest_allowlists/py36.txt index 94025b954f6c..d72f4f2f5c6c 100644 --- a/tests/stubtest_allowlists/py36.txt +++ b/tests/stubtest_allowlists/py36.txt @@ -6,6 +6,7 @@ _dummy_threading asyncio.Future.__init__ # Usually initialized from c object asyncio.futures.Future.__init__ # Usually initialized from c object asyncio.futures._TracebackLogger.__init__ +builtins.float.__setformat__ # Internal method for CPython test suite builtins.str.maketrans cmath.log collections.AsyncGenerator.ag_await @@ -129,4 +130,5 @@ tempfile.SpooledTemporaryFile.softspace tkinter.dnd.Icon tkinter.dnd.Tester tkinter.dnd.test +typing.[A-Z]\w*.__.*__ # many missing typing dunders in py36 xml.dom.xmlbuilder.DocumentLS.async diff --git a/tests/stubtest_allowlists/py37.txt b/tests/stubtest_allowlists/py37.txt index 987623d79667..5781ca29e0e5 100644 --- a/tests/stubtest_allowlists/py37.txt +++ b/tests/stubtest_allowlists/py37.txt @@ -8,6 +8,7 @@ asyncio.Future._callbacks # Usually initialized from c object asyncio.futures.Future.__init__ # Usually initialized from c object asyncio.futures.Future._callbacks # Usually initialized from c object builtins.dict.get +builtins.float.__set_format__ # Internal method for CPython test suite builtins.str.maketrans cmath.log collections.AsyncGenerator.ag_await diff --git a/tests/stubtest_allowlists/py38.txt b/tests/stubtest_allowlists/py38.txt index 13a72397cef4..def7aef73daf 100644 --- a/tests/stubtest_allowlists/py38.txt +++ b/tests/stubtest_allowlists/py38.txt @@ -16,6 +16,7 @@ asyncio.Future._callbacks # Usually initialized from c object asyncio.futures.Future.__init__ # Usually initialized from c object asyncio.futures.Future._callbacks # Usually initialized from c object builtins.dict.get +builtins.float.__set_format__ # Internal method for CPython test suite collections.AsyncGenerator.ag_await collections.AsyncGenerator.ag_code collections.AsyncGenerator.ag_frame diff --git a/tests/stubtest_allowlists/py39.txt b/tests/stubtest_allowlists/py39.txt index 3b16ecb95eae..e2405fbbfe88 100644 --- a/tests/stubtest_allowlists/py39.txt +++ b/tests/stubtest_allowlists/py39.txt @@ -6,6 +6,7 @@ _collections_abc.AsyncGenerator.ag_running _collections_abc.ItemsView.__reversed__ _collections_abc.KeysView.__reversed__ _collections_abc.ValuesView.__reversed__ +_weakref.ProxyType.__reversed__ # Doesn't really exist ast.Bytes.__new__ ast.Ellipsis.__new__ ast.ExtSlice.__new__ @@ -19,6 +20,7 @@ asyncio.Future._callbacks # Usually initialized from c object asyncio.futures.Future.__init__ # Usually initialized from c object asyncio.futures.Future._callbacks # Usually initialized from c object builtins.dict.get +builtins.float.__set_format__ # Internal method for CPython test suite collections.AsyncGenerator.ag_await collections.AsyncGenerator.ag_code collections.AsyncGenerator.ag_frame @@ -83,6 +85,7 @@ typing._TypedDict.pop typing._TypedDict.setdefault typing._TypedDict.update typing._TypedDict.values +weakref.ProxyType.__reversed__ # Doesn't really exist weakref.WeakValueDictionary.update xml.etree.ElementTree.XMLParser.__init__ # Defined in C so has general signature xml.etree.cElementTree.XMLParser.__init__ # Defined in C so has general signature @@ -146,7 +149,9 @@ pyexpat.XMLParserType.SkippedEntityHandler pyexpat.XMLParserType.intern stringprep.unicodedata # re-exported from unicodedata types.CoroutineType.cr_origin +types.GenericAlias.__mro_entries__ typing._SpecialForm.__call__ +typing._SpecialForm.__mro_entries__ unicodedata.UCD.is_normalized xml.parsers.expat.XMLParserType.SkippedEntityHandler xml.parsers.expat.XMLParserType.intern diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 7e61d8416c0c..48fc20fbc17d 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -33,7 +33,6 @@ argparse.Namespace.__getattr__ # The whole point of this class is its attribute asynchat.async_chat.encoding # Removal planned for 3.12, can add if someone needs this asynchat.async_chat.use_encoding # Removal planned for 3.12, can add if someone needs this asynchat.find_prefix_at_end # Removal planned for 3.12, can add if someone needs this -asynchat.__warningregistry__ # Removal planned for 3.12, can add if someone needs this asyncio.BaseEventLoop.subprocess_exec # BaseEventLoop adds several parameters and stubtest fails on the difference if we add them # Condition functions are exported in __init__ asyncio.Condition.acquire @@ -248,7 +247,6 @@ xml.parsers.expat.expat_CAPI # ========== _pydecimal.* # See comments in file _weakref.ProxyType.__bytes__ # Doesn't really exist -_weakref.ProxyType.__reversed__ # Doesn't really exist ast.NodeVisitor.visit_\w+ # Methods are discovered dynamically, see #3796 # Weird special builtins that are typed as functions, but aren't functions builtins.copyright @@ -258,7 +256,6 @@ builtins.float.__getformat__ # Internal method for CPython test suite builtins.float.__set_format__ # Internal method for CPython test suite builtins.help builtins.license -builtins.property.__set_name__ # Doesn't actually exist builtins.quit # These super() dunders don't seem to be particularly useful, # and having them pop up on autocomplete suggestions would be annoying @@ -308,7 +305,6 @@ codecs.StreamReaderWriter.\w+ codecs.StreamRecoder.\w+ urllib.response.addbase.\w+ weakref.ProxyType.__bytes__ # Doesn't actually exist -weakref.ProxyType.__reversed__ # Doesn't actually exist # Dynamically created, has unnecessary *args turtle.ScrolledCanvas.find_all @@ -472,7 +468,6 @@ email.contentmanager.get_text_content email.contentmanager.set_bytes_content email.contentmanager.set_message_content email.contentmanager.set_text_content -functools.partial.__vectorcalloffset__ pipes.Template.makepipeline pipes.Template.open_r pipes.Template.open_w @@ -534,7 +529,6 @@ distutils.cmd.Command.dump_options distutils.cmd.Command.ensure_finalized distutils.command.bdist distutils.command.bdist_rpm.DEBUG -distutils.command.build_ext.__warningregistry__ distutils.command.build_ext.USER_BASE distutils.command.build_scripts.ST_MODE distutils.command.install.* @@ -710,7 +704,6 @@ ctypes.ARRAY ctypes.SetPointerType ctypes.c_voidp ctypes.util.test -dbm.dumb._Database.__contains__ importlib.abc.Finder.find_module lib2to3.pgen2.grammar.Grammar.loads logging.config.BaseConfigurator @@ -769,5 +762,3 @@ tkinter.tix.ScrolledText tkinter.tix.ScrolledWindow tkinter.tix.Shell turtle.TNavigator.speed -types.GenericAlias.__mro_entries__ -typing._SpecialForm.__mro_entries__ From 5448f6471be572ca990159c658e41483522d51ab Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 4 Mar 2022 13:56:32 +0000 Subject: [PATCH 3/5] Allow --- tests/stubtest_allowlists/py36.txt | 8 ++++++++ tests/stubtest_allowlists/py37.txt | 8 ++++++++ tests/stubtest_allowlists/py38.txt | 8 ++++++++ tests/stubtest_allowlists/py39.txt | 6 ++++++ tests/stubtest_allowlists/py3_common.txt | 1 - 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/stubtest_allowlists/py36.txt b/tests/stubtest_allowlists/py36.txt index d72f4f2f5c6c..b3ce9269429e 100644 --- a/tests/stubtest_allowlists/py36.txt +++ b/tests/stubtest_allowlists/py36.txt @@ -6,6 +6,8 @@ _dummy_threading asyncio.Future.__init__ # Usually initialized from c object asyncio.futures.Future.__init__ # Usually initialized from c object asyncio.futures._TracebackLogger.__init__ +asyncio.locks._ContextManagerMixin.__enter__ # Always raises; deliberately omitted from the stub +asyncio.locks._ContextManagerMixin.__exit__ # Always raises; deliberately omitted from the stub builtins.float.__setformat__ # Internal method for CPython test suite builtins.str.maketrans cmath.log @@ -14,6 +16,12 @@ collections.AsyncGenerator.ag_code collections.AsyncGenerator.ag_frame collections.AsyncGenerator.ag_running collections.Callable +collections.Mapping.__reversed__ # Set to None at runtime for a better error message +# Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414. +collections.Set.__rand__ +collections.Set.__ror__ +collections.Set.__rsub__ +collections.Set.__rxor__ collections.UserString.maketrans datetime.datetime_CAPI distutils.command.bdist_wininst # see #6523 diff --git a/tests/stubtest_allowlists/py37.txt b/tests/stubtest_allowlists/py37.txt index 5781ca29e0e5..ca63c345e1be 100644 --- a/tests/stubtest_allowlists/py37.txt +++ b/tests/stubtest_allowlists/py37.txt @@ -7,6 +7,8 @@ asyncio.Future.__init__ # Usually initialized from c object asyncio.Future._callbacks # Usually initialized from c object asyncio.futures.Future.__init__ # Usually initialized from c object asyncio.futures.Future._callbacks # Usually initialized from c object +asyncio.locks._ContextManagerMixin.__enter__ # Always raises; deliberately omitted from the stub +asyncio.locks._ContextManagerMixin.__exit__ # Always raises; deliberately omitted from the stub builtins.dict.get builtins.float.__set_format__ # Internal method for CPython test suite builtins.str.maketrans @@ -16,6 +18,12 @@ collections.AsyncGenerator.ag_code collections.AsyncGenerator.ag_frame collections.AsyncGenerator.ag_running collections.Callable +collections.Mapping.__reversed__ # Set to None at runtime for a better error message +# Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414. +collections.Set.__rand__ +collections.Set.__ror__ +collections.Set.__rsub__ +collections.Set.__rxor__ collections.UserString.maketrans contextvars.Context.__init__ # Default C __init__ signature is wrong contextvars.ContextVar.get diff --git a/tests/stubtest_allowlists/py38.txt b/tests/stubtest_allowlists/py38.txt index def7aef73daf..d51f85d6ec1e 100644 --- a/tests/stubtest_allowlists/py38.txt +++ b/tests/stubtest_allowlists/py38.txt @@ -15,6 +15,8 @@ asyncio.Future.__init__ # Usually initialized from c object asyncio.Future._callbacks # Usually initialized from c object asyncio.futures.Future.__init__ # Usually initialized from c object asyncio.futures.Future._callbacks # Usually initialized from c object +asyncio.locks._ContextManagerMixin.__enter__ # Always raises; deliberately omitted from the stub +asyncio.locks._ContextManagerMixin.__exit__ # Always raises; deliberately omitted from the stub builtins.dict.get builtins.float.__set_format__ # Internal method for CPython test suite collections.AsyncGenerator.ag_await @@ -25,6 +27,12 @@ collections.Callable collections.ItemsView.__reversed__ collections.KeysView.__reversed__ collections.ValuesView.__reversed__ +collections.Mapping.__reversed__ # Set to None at runtime for a better error message +# Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414. +collections.Set.__rand__ +collections.Set.__ror__ +collections.Set.__rsub__ +collections.Set.__rxor__ contextvars.Context.__init__ # Default C __init__ signature is wrong dataclasses.field distutils.command.bdist_wininst # see #6523 diff --git a/tests/stubtest_allowlists/py39.txt b/tests/stubtest_allowlists/py39.txt index e2405fbbfe88..666290a70570 100644 --- a/tests/stubtest_allowlists/py39.txt +++ b/tests/stubtest_allowlists/py39.txt @@ -26,9 +26,15 @@ collections.AsyncGenerator.ag_code collections.AsyncGenerator.ag_frame collections.AsyncGenerator.ag_running collections.Callable +collections.Mapping.__reversed__ # Set to None at runtime for a better error message collections.ItemsView.__reversed__ collections.KeysView.__reversed__ collections.ValuesView.__reversed__ +# Adding these reflected dunders to `typing.AbstractSet` causes a large number of false-positives. See #7414. +collections.Set.__rand__ +collections.Set.__ror__ +collections.Set.__rsub__ +collections.Set.__rxor__ contextvars.Context.__init__ # Default C __init__ signature is wrong contextlib.AbstractAsyncContextManager.__class_getitem__ contextlib.AbstractContextManager.__class_getitem__ diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 48fc20fbc17d..cc2accf895e1 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -253,7 +253,6 @@ builtins.copyright builtins.credits builtins.exit builtins.float.__getformat__ # Internal method for CPython test suite -builtins.float.__set_format__ # Internal method for CPython test suite builtins.help builtins.license builtins.quit From ac9653189284d946fa18ee2a7e6ad1ace0a2c126 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 4 Mar 2022 14:03:47 +0000 Subject: [PATCH 4/5] Allow --- tests/stubtest_allowlists/darwin-py310.txt | 1 + tests/stubtest_allowlists/py37.txt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/tests/stubtest_allowlists/darwin-py310.txt b/tests/stubtest_allowlists/darwin-py310.txt index 8a3185cd8c13..3f08864b49bc 100644 --- a/tests/stubtest_allowlists/darwin-py310.txt +++ b/tests/stubtest_allowlists/darwin-py310.txt @@ -4,3 +4,4 @@ curses.color_pair # Exists at runtime, but missing from stubs mmap.MADV_FREE +distutils.util.__warningregistry__ diff --git a/tests/stubtest_allowlists/py37.txt b/tests/stubtest_allowlists/py37.txt index ca63c345e1be..e0d94bde87cc 100644 --- a/tests/stubtest_allowlists/py37.txt +++ b/tests/stubtest_allowlists/py37.txt @@ -3,6 +3,8 @@ _collections_abc.AsyncGenerator.ag_code _collections_abc.AsyncGenerator.ag_frame _collections_abc.AsyncGenerator.ag_running _dummy_threading +asyncio.AbstractEventLoop.run_in_executor # allowed to return a Future, changed in 3.8 +asyncio.events.AbstractEventLoop.run_in_executor # allowed to return a Future, changed in 3.8 asyncio.Future.__init__ # Usually initialized from c object asyncio.Future._callbacks # Usually initialized from c object asyncio.futures.Future.__init__ # Usually initialized from c object From 7e54ef8325b13c1a72f0a26d7c27f4d608af1205 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 4 Mar 2022 14:09:49 +0000 Subject: [PATCH 5/5] Add `multiprocessing.context.DefaultContext.__all__`; allow --- stdlib/multiprocessing/context.pyi | 4 +++- tests/stubtest_allowlists/linux-py310.txt | 1 + tests/stubtest_allowlists/py310.txt | 1 - tests/stubtest_allowlists/win32-py310.txt | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index 28ec0b140566..db8e6216b6ad 100644 --- a/stdlib/multiprocessing/context.pyi +++ b/stdlib/multiprocessing/context.pyi @@ -8,7 +8,7 @@ from multiprocessing import queues, synchronize from multiprocessing.pool import Pool as _Pool from multiprocessing.process import BaseProcess from multiprocessing.sharedctypes import SynchronizedArray, SynchronizedBase -from typing import Any, TypeVar, Union, overload +from typing import Any, ClassVar, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 8): @@ -139,6 +139,8 @@ class DefaultContext(BaseContext): def set_start_method(self, method: str | None, force: bool = ...) -> None: ... def get_start_method(self, allow_none: bool = ...) -> str: ... def get_all_start_methods(self) -> list[str]: ... + if sys.version_info < (3, 8): + __all__: ClassVar[list[str]] _default_context: DefaultContext diff --git a/tests/stubtest_allowlists/linux-py310.txt b/tests/stubtest_allowlists/linux-py310.txt index d435cdd0a567..fd9123733be0 100644 --- a/tests/stubtest_allowlists/linux-py310.txt +++ b/tests/stubtest_allowlists/linux-py310.txt @@ -18,6 +18,7 @@ signal.sigwaitinfo select.epoll.register # Exists at runtime, but missing from stubs +distutils.command.build_ext.__warningregistry__ os.EFD_CLOEXEC os.EFD_NONBLOCK os.EFD_SEMAPHORE diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index 5ab0733acf52..911510b3846f 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -178,7 +178,6 @@ asyncio.AbstractEventLoop.connect_accepted_socket asyncio.events.AbstractEventLoop.connect_accepted_socket bdb.Breakpoint.clearBreakpoints dbm.dumb._Database.__contains__ -distutils.command.build_ext.__warningregistry__ distutils.dist.DistributionMetadata.set_classifiers distutils.dist.DistributionMetadata.set_keywords distutils.dist.DistributionMetadata.set_platforms diff --git a/tests/stubtest_allowlists/win32-py310.txt b/tests/stubtest_allowlists/win32-py310.txt index 2fcacc00a5b2..364d1144d00e 100644 --- a/tests/stubtest_allowlists/win32-py310.txt +++ b/tests/stubtest_allowlists/win32-py310.txt @@ -20,6 +20,7 @@ asyncio.IocpProactor.recvfrom asyncio.IocpProactor.sendto asyncio.windows_events.IocpProactor.recvfrom asyncio.windows_events.IocpProactor.sendto +distutils.command.build_ext.__warningregistry__ msvcrt.GetErrorMode socket.MsgFlag.MSG_ERRQUEUE subprocess.STARTUPINFO.copy