Skip to content

Use latest stubtest in CI #7438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/stubtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion stdlib/multiprocessing/context.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/stubtest_allowlists/darwin-py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ curses.color_pair

# Exists at runtime, but missing from stubs
mmap.MADV_FREE
distutils.util.__warningregistry__
1 change: 1 addition & 0 deletions tests/stubtest_allowlists/linux-py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,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__
Expand All @@ -41,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__
Expand Down Expand Up @@ -78,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__
Expand All @@ -100,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
Expand All @@ -112,6 +137,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__

Expand Down Expand Up @@ -146,13 +173,16 @@ _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.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
Expand Down
10 changes: 10 additions & 0 deletions tests/stubtest_allowlists/py36.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ _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
collections.AsyncGenerator.ag_await
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
Expand Down Expand Up @@ -129,4 +138,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
11 changes: 11 additions & 0 deletions tests/stubtest_allowlists/py37.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,29 @@ _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
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
cmath.log
collections.AsyncGenerator.ag_await
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
Expand Down
9 changes: 9 additions & 0 deletions tests/stubtest_allowlists/py38.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ 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
collections.AsyncGenerator.ag_code
collections.AsyncGenerator.ag_frame
Expand All @@ -24,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
Expand Down
11 changes: 11 additions & 0 deletions tests/stubtest_allowlists/py39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand All @@ -19,14 +20,21 @@ 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
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__
Expand Down Expand Up @@ -83,6 +91,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
Expand Down Expand Up @@ -146,7 +155,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
15 changes: 14 additions & 1 deletion tests/stubtest_allowlists/py3_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -240,14 +246,21 @@ 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
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.help
builtins.license
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
Expand Down Expand Up @@ -290,6 +303,7 @@ sys.tracebacklimit
codecs.StreamReaderWriter.\w+
codecs.StreamRecoder.\w+
urllib.response.addbase.\w+
weakref.ProxyType.__bytes__ # Doesn't actually exist

# Dynamically created, has unnecessary *args
turtle.ScrolledCanvas.find_all
Expand Down Expand Up @@ -668,7 +682,6 @@ pkgutil.ImpLoader.source
# ==========
# Exists at runtime, but missing from stubs
# ==========
__main__.\w+
_json.encode_basestring
_thread.LockType.acquire_lock
_thread.LockType.locked_lock
Expand Down
1 change: 1 addition & 0 deletions tests/stubtest_allowlists/win32-py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/stubtest_third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down