diff --git a/requirements-tests.txt b/requirements-tests.txt index cb157edd8127..ee440ad9c08a 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -5,7 +5,7 @@ flake8-bugbear==22.7.1 # must match .pre-commit-config.yaml flake8-noqa==1.2.9 # must match .pre-commit-config.yaml flake8-pyi==22.8.2 # must match .pre-commit-config.yaml isort==5.10.1 # must match .pre-commit-config.yaml -mypy==0.971 +mypy==0.981 packaging==21.3 pycln==2.1.1 # must match .pre-commit-config.yaml pyyaml==6.0 diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index a312b4da168f..971af2498b1a 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1952,7 +1952,7 @@ if sys.version_info >= (3, 11): @overload def subgroup(self: Self, __condition: Callable[[_BaseExceptionT_co], bool]) -> Self | None: ... @overload - def split( + def split( # type: ignore[misc] # complaints about overlapping overloads self: Self, __condition: type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...] ) -> tuple[BaseExceptionGroup[_BaseExceptionT] | None, Self | None]: ... @overload @@ -1972,7 +1972,7 @@ if sys.version_info >= (3, 11): @overload def subgroup(self: Self, __condition: Callable[[_ExceptionT_co], bool]) -> Self | None: ... @overload # type: ignore[override] - def split( + def split( # type: ignore[misc] # complaints about overlapping overloads self: Self, __condition: type[_ExceptionT] | tuple[type[_ExceptionT], ...] ) -> tuple[ExceptionGroup[_ExceptionT] | None, Self | None]: ... @overload diff --git a/stdlib/importlib/metadata/__init__.pyi b/stdlib/importlib/metadata/__init__.pyi index 99fecb41497d..01e35db5815e 100644 --- a/stdlib/importlib/metadata/__init__.pyi +++ b/stdlib/importlib/metadata/__init__.pyi @@ -41,6 +41,9 @@ class _EntryPointBase(NamedTuple): class EntryPoint(_EntryPointBase): pattern: ClassVar[Pattern[str]] + if sys.version_info >= (3, 11): + def __init__(self, name: str, value: str, group: str) -> None: ... + def load(self) -> Any: ... # Callable[[], Any] or an importable module @property def extras(self) -> list[str]: ... diff --git a/stubs/PyYAML/@tests/stubtest_allowlist.txt b/stubs/PyYAML/@tests/stubtest_allowlist.txt index 3dafb90cefeb..abc7ed9183dc 100644 --- a/stubs/PyYAML/@tests/stubtest_allowlist.txt +++ b/stubs/PyYAML/@tests/stubtest_allowlist.txt @@ -1,4 +1,2 @@ # yaml._yaml is for backwards compatibility so none of it matters anyway -yaml._yaml.CEmitter.__pyx_vtable__ -yaml._yaml.CParser.__pyx_vtable__ yaml._yaml.__test__ diff --git a/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt b/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt index 67032a3cf580..4d6eb0a078e3 100644 --- a/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt +++ b/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt @@ -14,10 +14,7 @@ sqlalchemy.ext.declarative.as_declarative sqlalchemy.orm.collections.InstrumentedList.* sqlalchemy.orm.collections.InstrumentedSet.* sqlalchemy.orm.collections.MappedCollection.* -sqlalchemy.util.OrderedDict.get sqlalchemy.util.StringIO.* -sqlalchemy.util.byte_buffer.* -sqlalchemy.util.column_dict.get # method arguments starting with double underscores in the implementation sqlalchemy.testing.resolve_lambda diff --git a/stubs/cffi/@tests/stubtest_allowlist.txt b/stubs/cffi/@tests/stubtest_allowlist.txt index 2fa3441d5c74..8884550884fe 100644 --- a/stubs/cffi/@tests/stubtest_allowlist.txt +++ b/stubs/cffi/@tests/stubtest_allowlist.txt @@ -9,12 +9,6 @@ cffi.(api.)?FFI.buffer # Exists at runtime, but missing from stubs cffi.vengine_cpy.__warningregistry__ -# Alias to io.StringIO, which has the same allowlist -cffi.recompiler.NativeIO.seek -cffi.recompiler.NativeIO.truncate -cffi.verifier.NativeIO.seek -cffi.verifier.NativeIO.truncate - # Unnecessary re-exports cffi.cparser.COMMON_TYPES cffi.verifier.__version_verifier_modules__ \ No newline at end of file diff --git a/stubs/hdbcli/@tests/stubtest_allowlist.txt b/stubs/hdbcli/@tests/stubtest_allowlist.txt index 283ddd3b2062..d73612be9c97 100644 --- a/stubs/hdbcli/@tests/stubtest_allowlist.txt +++ b/stubs/hdbcli/@tests/stubtest_allowlist.txt @@ -2,7 +2,3 @@ hdbcli.dbapi.Error.errorcode hdbcli.dbapi.Error.errortext hdbcli.dbapi.Warning.errorcode hdbcli.dbapi.Warning.errortext -# Similar issues to builtins.memoryview -hdbcli.dbapi.BINARY.__iter__ -hdbcli.dbapi.BINARY.cast -hdbcli.dbapi.BINARY.__contains__ diff --git a/stubs/html5lib/@tests/stubtest_allowlist.txt b/stubs/html5lib/@tests/stubtest_allowlist.txt deleted file mode 100644 index 82dbdb726b09..000000000000 --- a/stubs/html5lib/@tests/stubtest_allowlist.txt +++ /dev/null @@ -1,3 +0,0 @@ -# Misnamed first argument in implementation -html5lib._inputstream.EncodingBytes.__new__ -html5lib._tokenizer.attributeMap.get diff --git a/stubs/html5lib/html5lib/_inputstream.pyi b/stubs/html5lib/html5lib/_inputstream.pyi index 56096a0589df..0f5842240f68 100644 --- a/stubs/html5lib/html5lib/_inputstream.pyi +++ b/stubs/html5lib/html5lib/_inputstream.pyi @@ -72,7 +72,7 @@ class HTMLBinaryInputStream(HTMLUnicodeInputStream): def detectEncodingMeta(self): ... class EncodingBytes(bytes): - def __new__(cls, value): ... + def __new__(self, value): ... def __init__(self, value) -> None: ... def __iter__(self): ... def __next__(self): ... diff --git a/stubs/jsonschema/@tests/stubtest_allowlist.txt b/stubs/jsonschema/@tests/stubtest_allowlist.txt deleted file mode 100644 index 906e10ab8a4b..000000000000 --- a/stubs/jsonschema/@tests/stubtest_allowlist.txt +++ /dev/null @@ -1,2 +0,0 @@ -# TODO: remove _FormatCheckCallable when mypy 0.980 is released -jsonschema._format._FormatCheckCallable diff --git a/stubs/keyboard/@tests/stubtest_allowlist.txt b/stubs/keyboard/@tests/stubtest_allowlist.txt index 8ecec31a6b87..d8684a128cca 100644 --- a/stubs/keyboard/@tests/stubtest_allowlist.txt +++ b/stubs/keyboard/@tests/stubtest_allowlist.txt @@ -4,14 +4,5 @@ keyboard._keyboard_event.KeyboardEvent.scan_code # Defaults don't align with possible values keyboard.mouse.on_button keyboard.mouse.wait -# Private modules and tests +# TODO: Should this be allowlisted? keyboard.__main__ -keyboard._darwinkeyboard -keyboard._darwinmouse -keyboard._keyboard_tests -keyboard._mouse_tests -keyboard._nixcommon -keyboard._nixkeyboard -keyboard._nixmouse -keyboard._winkeyboard -keyboard._winmouse diff --git a/stubs/pyinstaller/@tests/stubtest_allowlist.txt b/stubs/pyinstaller/@tests/stubtest_allowlist.txt index c9c278ea1a3c..0c41373b7fd3 100644 --- a/stubs/pyinstaller/@tests/stubtest_allowlist.txt +++ b/stubs/pyinstaller/@tests/stubtest_allowlist.txt @@ -36,7 +36,3 @@ PyInstaller.utils.osx PyInstaller.utils.run_tests PyInstaller.utils.tests PyInstaller.utils.win32.* -# Explicitly private implementation details -PyInstaller\._.* -PyInstaller.isolated._child -PyInstaller.utils._gitrevision diff --git a/stubs/redis/@tests/stubtest_allowlist.txt b/stubs/redis/@tests/stubtest_allowlist.txt index 3eadfa64d944..fab69ce27152 100644 --- a/stubs/redis/@tests/stubtest_allowlist.txt +++ b/stubs/redis/@tests/stubtest_allowlist.txt @@ -1,21 +1,6 @@ redis.client.Pipeline.transaction # instance attribute has same name as superclass method redis.ocsp # requires cryptography to be installed -# TypeAlias-related problems -redis.asyncio.client.CommandStackT -redis.asyncio.client.CommandT -redis.asyncio.client.PubSubHandler -redis.asyncio.connection.ExceptionMappingT - -# Protocol-related problems -redis.asyncio.client.AsyncPubsubWorkerExceptionHandler.__init__ -redis.asyncio.client.AsyncResponseCallbackProtocol.__init__ -redis.asyncio.client.PubsubWorkerExceptionHandler.__init__ -redis.asyncio.client.ResponseCallbackProtocol.__init__ -redis.asyncio.connection.AsyncConnectCallbackProtocol.__init__ -redis.asyncio.connection.ConnectCallbackProtocol.__init__ -redis.typing.CommandsProtocol.__init__ - # async def mismatch problems redis.asyncio.client.Pipeline.command_info redis.asyncio.client.Pipeline.debug_segfault @@ -25,8 +10,6 @@ redis.asyncio.client.Pipeline.script_debug redis.asyncio.client.Pipeline.shutdown # unclear problems -redis.Sentinel.master_for -redis.Sentinel.slave_for redis.asyncio.Sentinel.master_for redis.asyncio.Sentinel.slave_for redis.asyncio.sentinel.Sentinel.master_for diff --git a/stubs/six/@tests/stubtest_allowlist.txt b/stubs/six/@tests/stubtest_allowlist.txt index c43893f13561..16cd857f966f 100644 --- a/stubs/six/@tests/stubtest_allowlist.txt +++ b/stubs/six/@tests/stubtest_allowlist.txt @@ -21,5 +21,4 @@ six.viewkeys six.viewvalues # Unclear problems -six.Iterator.__init__ six.callable diff --git a/stubs/tqdm/tqdm/contrib/logging.pyi b/stubs/tqdm/tqdm/contrib/logging.pyi index f885878793be..0bb9e0e4e8be 100644 --- a/stubs/tqdm/tqdm/contrib/logging.pyi +++ b/stubs/tqdm/tqdm/contrib/logging.pyi @@ -13,7 +13,9 @@ def logging_redirect_tqdm( ) -> _GeneratorContextManager[None]: ... # TODO type *args, **kwargs here more precisely +# The type ignore is because mypy complains that the second overload will never be matched +# (I'm not sure that's true) @overload def tqdm_logging_redirect(*args, tqdm_class: Callable[..., _TqdmT], **kwargs) -> _GeneratorContextManager[_TqdmT]: ... @overload -def tqdm_logging_redirect(*args, **kwargs) -> _GeneratorContextManager[std_tqdm[Incomplete]]: ... +def tqdm_logging_redirect(*args, **kwargs) -> _GeneratorContextManager[std_tqdm[Incomplete]]: ... # type: ignore[misc] diff --git a/stubs/urllib3/@tests/stubtest_allowlist.txt b/stubs/urllib3/@tests/stubtest_allowlist.txt index 74eb15342438..317477c60ed2 100644 --- a/stubs/urllib3/@tests/stubtest_allowlist.txt +++ b/stubs/urllib3/@tests/stubtest_allowlist.txt @@ -1,15 +1,4 @@ -# TODO: remove ResponseCls ignore when https://github.com/python/mypy/issues/13316 is closed -urllib3.HTTPConnectionPool.ResponseCls -urllib3.HTTPConnectionPool.__init__ -urllib3.HTTPConnectionPool.urlopen -urllib3.HTTPSConnectionPool.__init__ urllib3.NullHandler -urllib3.PoolManager.connection_from_host -urllib3.PoolManager.connection_from_url -urllib3.PoolManager.urlopen -urllib3.ProxyManager.__init__ -urllib3.ProxyManager.connection_from_host -urllib3.ProxyManager.urlopen urllib3._collections.HTTPHeaderDict.from_httplib urllib3._collections.HTTPHeaderDict.getlist urllib3._collections.RLock @@ -18,14 +7,11 @@ urllib3.connection.HTTPSConnection.__init__ urllib3.connection.VerifiedHTTPSConnection.__init__ urllib3.connection.VerifiedHTTPSConnection.set_cert urllib3.connectionpool.ConnectionError -urllib3.connectionpool.HTTPConnection.request # TODO: remove ResponseCls ignore when https://github.com/python/mypy/issues/13316 is closed urllib3.connectionpool.HTTPConnectionPool.ResponseCls urllib3.connectionpool.HTTPConnectionPool.__init__ urllib3.connectionpool.HTTPConnectionPool.urlopen -urllib3.connectionpool.HTTPSConnection.__init__ urllib3.connectionpool.HTTPSConnectionPool.__init__ -urllib3.connectionpool.RequestMethods.request_encode_url urllib3.connectionpool.VerifiedHTTPSConnection.__init__ urllib3.connectionpool.VerifiedHTTPSConnection.set_cert urllib3.packages.ssl_match_hostname diff --git a/stubs/xxhash/@tests/stubtest_allowlist.txt b/stubs/xxhash/@tests/stubtest_allowlist.txt deleted file mode 100644 index fcb981c2f4ea..000000000000 --- a/stubs/xxhash/@tests/stubtest_allowlist.txt +++ /dev/null @@ -1 +0,0 @@ -xxhash._xxhash diff --git a/tests/mypy_test.py b/tests/mypy_test.py index 8c113863f215..6299e8d01897 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -13,7 +13,7 @@ from io import StringIO from itertools import product from pathlib import Path -from typing import TYPE_CHECKING, NamedTuple +from typing import TYPE_CHECKING, Any, NamedTuple if TYPE_CHECKING: from _typeshed import StrPath @@ -157,7 +157,7 @@ def add_files(files: list[Path], seen: set[str], module: Path, args: TestConfig) class MypyDistConf(NamedTuple): module_name: str - values: dict + values: dict[str, dict[str, Any]] # The configuration section in the metadata file looks like the following, with multiple module sections possible diff --git a/tests/regr_test.py b/tests/regr_test.py index 02f27af80f97..2bbf4733d78c 100644 --- a/tests/regr_test.py +++ b/tests/regr_test.py @@ -130,7 +130,10 @@ def test_testcase_directory(package: PackageInfo, version: str, platform: str) - os.mkdir(new_typeshed) shutil.copytree(Path("stdlib"), new_typeshed / "stdlib") requirements = get_recursive_requirements(package_name) - for requirement in requirements: + # mypy refuses to consider a directory a "valid typeshed directory" + # unless there's a stubs/mypy-extensions path inside it, + # so add that to the list of stubs to copy over to the new directory + for requirement in requirements + ["mypy-extensions"]: shutil.copytree(Path("stubs", requirement), new_typeshed / "stubs" / requirement) env_vars["MYPYPATH"] = os.pathsep.join(map(str, new_typeshed.glob("stubs/*"))) flags.extend(["--custom-typeshed-dir", str(td_path / "typeshed")]) diff --git a/tests/stubtest_allowlists/darwin.txt b/tests/stubtest_allowlists/darwin.txt index 6e8ef83e698a..e50de9e8734c 100644 --- a/tests/stubtest_allowlists/darwin.txt +++ b/tests/stubtest_allowlists/darwin.txt @@ -35,8 +35,6 @@ _ctypes.dlopen _ctypes.dlsym posix.NGROUPS_MAX -posix.error.characters_written -resource.error.characters_written select.POLLRDHUP webbrowser.MacOSX.__init__ diff --git a/tests/stubtest_allowlists/linux.txt b/tests/stubtest_allowlists/linux.txt index af5a21ef5be7..3f543305295b 100644 --- a/tests/stubtest_allowlists/linux.txt +++ b/tests/stubtest_allowlists/linux.txt @@ -44,10 +44,6 @@ winsound # multiprocessing.popen_spawn_win32 exists on Linux but fail to import multiprocessing.popen_spawn_win32 -# Aliases for OSError -posix.error.characters_written -resource.error.characters_written - # Platform differences that cannot be captured by the type system fcntl.I_[A-Z0-9_]+ os.SCHED_[A-Z_]+ diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index c9ddd382d767..415167af26d6 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -17,8 +17,7 @@ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolv gettext.install gettext.translation hmac.new # Stub is a white lie; see comments in the stub -importlib.metadata._meta.SimplePath.__div__ # See comments -importlib.metadata._meta.SimplePath.__truediv__ # See comments +importlib.metadata._meta.SimplePath.__truediv__ # See comments in the stub ipaddress.IPv4Interface.hostmask ipaddress.IPv6Interface.hostmask ipaddress._BaseNetwork.broadcast_address @@ -73,7 +72,6 @@ _csv.Writer asynchat.__warningregistry__ # Removal planned for 3.12, can add if someone needs this bdb.Breakpoint.clearBreakpoints distutils.util.get_host_platform -functools.partial.__vectorcalloffset__ # undocumented implementation detail inspect.Signature.from_builtin # Removed in 3.11, can add if someone needs this inspect.Signature.from_function # Removed in 3.11, can add if someone needs this multiprocessing.managers.SharedMemoryServer.create @@ -148,19 +146,6 @@ queue.SimpleQueue.__init__ xml.etree.ElementTree.XMLParser.__init__ xml.etree.cElementTree.XMLParser.__init__ -# Inherits __init__ from typing.Protocol -importlib.abc.Traversable.__init__ -importlib.metadata.PackageMetadata.__init__ -importlib.metadata._meta.PackageMetadata.__init__ -importlib.metadata._meta.SimplePath.__init__ -typing.SupportsAbs.__init__ -typing.SupportsBytes.__init__ -typing.SupportsComplex.__init__ -typing.SupportsFloat.__init__ -typing.SupportsIndex.__init__ -typing.SupportsInt.__init__ -typing.SupportsRound.__init__ - ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154 os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all PathLike classes to implement class_getitem types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime diff --git a/tests/stubtest_allowlists/py311.txt b/tests/stubtest_allowlists/py311.txt index ff52d9a4beae..e7b27930afc7 100644 --- a/tests/stubtest_allowlists/py311.txt +++ b/tests/stubtest_allowlists/py311.txt @@ -12,15 +12,12 @@ _collections_abc.MappingView.__class_getitem__ _collections_abc.ValuesView.__reversed__ _csv.Reader _csv.Writer -_operator.attrgetter.__vectorcalloffset__ -_operator.itemgetter.__vectorcalloffset__ argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group asynchat.__warningregistry__ # Removal planned for 3.12, can add if someone needs this configparser.LegacyInterpolation.__init__ enum.Enum.__init__ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve ftplib.FTP.trust_server_pasv_ipv4_address -functools.partial.__vectorcalloffset__ ipaddress.IPv4Interface.hostmask ipaddress.IPv6Interface.hostmask ipaddress._BaseNetwork.broadcast_address @@ -32,8 +29,6 @@ multiprocessing.managers.SharedMemoryServer.release_segment multiprocessing.managers.SharedMemoryServer.shutdown multiprocessing.managers.SharedMemoryServer.track_segment multiprocessing.spawn._main -operator.attrgetter.__vectorcalloffset__ -operator.itemgetter.__vectorcalloffset__ # platform.uname_result's processor field is now dynamically made to exist platform.uname_result.__match_args__ platform.uname_result.__new__ @@ -93,7 +88,6 @@ os.path.join _collections_abc.AsyncGenerator.athrow # async at runtime, deliberately not in the stub, see #7491. Pos-only differences also. _weakref.ProxyType.__reversed__ # Doesn't really exist builtins.property.__set_name__ # Doesn't actually exist -enum.StrEnum.value # read-only property at runtime but too magical for stubtest hmac.new # Stub is a white lie; see comments in the stub http.HTTPMethod.description # mutable instance attribute at runtime but we pretend it's a property pickle.Pickler.reducer_override # implemented in C pickler @@ -103,25 +97,6 @@ types.GenericAlias.__mro_entries__ weakref.ProxyType.__reversed__ # Doesn't really exist inspect._ParameterKind.description # Still exists, but stubtest can't see it -# Inherits __init__ from typing.Protocol (https://github.com/python/mypy/issues/12820) -importlib.abc.Traversable.__init__ -importlib.metadata.EntryPoint.__init__ -importlib.metadata.PackageMetadata.__init__ -importlib.metadata._meta.PackageMetadata.__init__ -importlib.metadata._meta.SimplePath.__init__ -typing.SupportsAbs.__init__ -typing.SupportsBytes.__init__ -typing.SupportsComplex.__init__ -typing.SupportsFloat.__init__ -typing.SupportsIndex.__init__ -typing.SupportsInt.__init__ -typing.SupportsRound.__init__ -wsgiref.types.ErrorStream.__init__ -wsgiref.types.FileWrapper.__init__ -wsgiref.types.InputStream.__init__ -wsgiref.types.StartResponse.__init__ -wsgiref.types._Readable.__init__ - # C signature is broader than what is actually accepted ast.Bytes.__new__ ast.Ellipsis.__new__ @@ -169,12 +144,6 @@ typing._TypedDict.values # White lies around defaults dataclasses.KW_ONLY -# https://github.com/python/mypy/issues/13114 -wsgiref.types.WSGIEnvironment - -# https://github.com/python/mypy/issues/12821 (stubtest bug with Callable type alias) -wsgiref.types.WSGIApplication - # stubtest confuses stdlib distutils with setuptools-bundled distutils (#8410), # and the whole directory is going to be removed in 3.12 anyway distutils\..* diff --git a/tests/stubtest_allowlists/py37.txt b/tests/stubtest_allowlists/py37.txt index d4808f48ba92..c02c424c867b 100644 --- a/tests/stubtest_allowlists/py37.txt +++ b/tests/stubtest_allowlists/py37.txt @@ -45,16 +45,12 @@ typing.NamedTuple._make typing.NamedTuple._replace typing._SpecialForm.__new__ typing.runtime_checkable -typing.Text.maketrans uuid.UUID.int uuid.UUID.is_safe uuid.getnode # undocumented, unused parameter getters that was later removed xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495 xml.etree.cElementTree.TreeBuilder.start # bpo-39495 -sqlite3.OptimizedUnicode.maketrans -sqlite3.dbapi2.OptimizedUnicode.maketrans - collections.Coroutine.cr_await collections.Coroutine.cr_code collections.Coroutine.cr_frame @@ -141,10 +137,6 @@ collections.Set.__rxor__ builtins.memoryview.__iter__ # C type that implements __getitem__ builtins.memoryview.cast # inspect.signature is incorrect about shape being kw-only -sqlite3.dbapi2.Binary.__iter__ # C type that implements __getitem__ -sqlite3.dbapi2.Binary.cast # inspect.signature is incorrect about shape being kw-only -sqlite3.Binary.__iter__ # C type that implements __getitem__ -sqlite3.Binary.cast # inspect.signature is incorrect about shape being kw-only # C signature is broader than what is actually accepted queue.SimpleQueue.__init__ diff --git a/tests/stubtest_allowlists/py38.txt b/tests/stubtest_allowlists/py38.txt index 1a34a2ca91ad..44eebbdfd7fd 100644 --- a/tests/stubtest_allowlists/py38.txt +++ b/tests/stubtest_allowlists/py38.txt @@ -57,13 +57,6 @@ typing.NamedTuple.__new__ typing.NamedTuple._asdict typing.NamedTuple._make typing.NamedTuple._replace -typing.SupportsAbs.__init__ -typing.SupportsBytes.__init__ -typing.SupportsComplex.__init__ -typing.SupportsFloat.__init__ -typing.SupportsIndex.__init__ -typing.SupportsInt.__init__ -typing.SupportsRound.__init__ typing._SpecialForm.__new__ weakref.WeakValueDictionary.update xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495 @@ -160,10 +153,6 @@ collections.Set.__rxor__ builtins.memoryview.__iter__ # C type that implements __getitem__ builtins.memoryview.cast # inspect.signature is incorrect about shape being kw-only -sqlite3.dbapi2.Binary.__iter__ # C type that implements __getitem__ -sqlite3.dbapi2.Binary.cast # inspect.signature is incorrect about shape being kw-only -sqlite3.Binary.__iter__ # C type that implements __getitem__ -sqlite3.Binary.cast # inspect.signature is incorrect about shape being kw-only # C signature is broader than what is actually accepted queue.SimpleQueue.__init__ diff --git a/tests/stubtest_allowlists/py39.txt b/tests/stubtest_allowlists/py39.txt index 8b8515cf02ff..719849e83711 100644 --- a/tests/stubtest_allowlists/py39.txt +++ b/tests/stubtest_allowlists/py39.txt @@ -36,7 +36,6 @@ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolv gettext.install gettext.translation hmac.new # Stub is a white lie; see comments in the stub -importlib.abc.Traversable.__init__ # Inherits __init__ from typing.Protocol inspect.Signature.from_builtin # Removed in 3.11, can add if someone needs this inspect.Signature.from_function # Removed in 3.11, can add if someone needs this ipaddress.IPv4Interface.hostmask @@ -55,13 +54,6 @@ tkinter.Tk.split types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime types.GenericAlias.__getattr__ types.GenericAlias.__call__ # Would be complicated to fix properly, Any could silence problems. #6392 -typing.SupportsAbs.__init__ -typing.SupportsBytes.__init__ -typing.SupportsComplex.__init__ -typing.SupportsFloat.__init__ -typing.SupportsIndex.__init__ -typing.SupportsInt.__init__ -typing.SupportsRound.__init__ typing._TypedDict.__delitem__ typing._TypedDict.__ior__ typing._TypedDict.__or__ @@ -151,10 +143,6 @@ collections.Set.__rxor__ builtins.memoryview.__iter__ # C type that implements __getitem__ builtins.memoryview.cast # inspect.signature is incorrect about shape being kw-only -sqlite3.dbapi2.Binary.__iter__ # C type that implements __getitem__ -sqlite3.dbapi2.Binary.cast # inspect.signature is incorrect about shape being kw-only -sqlite3.Binary.__iter__ # C type that implements __getitem__ -sqlite3.Binary.cast # inspect.signature is incorrect about shape being kw-only # C signature is broader than what is actually accepted queue.SimpleQueue.__init__ diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 5c33002d0b7d..e55eec86a642 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -46,12 +46,11 @@ asyncio.locks.Condition.locked asyncio.locks.Condition.release asyncio.proactor_events.BaseProactorEventLoop.sock_recv # nbytes parameter has different name 'n' in implementation asyncio.selector_events.BaseSelectorEventLoop.sock_recv # nbytes parameter has different name 'n' in implementation +builtins.OSError.characters_written # GetSetDescriptor that always raises AttributeError builtins.dict.get builtins.ellipsis # type is not exposed anywhere builtins.function builtins.memoryview.__contains__ # C type that implements __getitem__ -sqlite3.dbapi2.Binary.__contains__ # C type that implements __getitem__ -sqlite3.Binary.__contains__ # C type that implements __getitem__ builtins.object.__init__ # default C signature is incorrect builtins.type.__dict__ # read-only but not actually a property; stubtest thinks it's a mutable attribute. bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set @@ -133,6 +132,9 @@ lib2to3.pytree.BasePattern.__new__ lib2to3.pytree.BasePattern.type lib2to3.pytree.NegatedPattern.match lib2to3.pytree.NegatedPattern.match_seq +# LC_MESSAGES is sometimes present in __all__, sometimes not, +# so stubtest will sometimes complain about exported names being different at runtime to the exported names in the stub +(locale)? multiprocessing.JoinableQueue multiprocessing.Queue multiprocessing.SimpleQueue @@ -389,14 +391,6 @@ builtins.super.__self__ builtins.super.__self_class__ builtins.super.__thisclass__ -# Enum `name` and `value` are special properties that exists at runtime, but stubtest can't detect -# https://github.com/python/typeshed/pull/6576#issuecomment-992538677 -enum.Enum.name -enum.Enum.value -enum.Flag.name -enum.Flag.value -enum.IntEnum.value - # These enums derive from (int, IntEnum) or (str, Enum). pstats.SortKey.__new__ tkinter.EventType.__new__ @@ -423,17 +417,6 @@ ssl.PROTOCOL_SSLv2 ssl.PROTOCOL_SSLv3 ssl.RAND_egd -# GetSetDescriptor that always raises AttributeError -builtins.OSError.characters_written -# Aliases for OSError -_socket.error.characters_written -builtins.EnvironmentError.characters_written -builtins.IOError.characters_written -dbm.dumb.error.characters_written -os.error.characters_written -select.error.characters_written -socket.error.characters_written - collections.abc.* # Types are re-exported from _collections_abc, so errors should be fixed there distutils.command.check.SilentReporter # only defined if docutils in installed hmac.HMAC.blocksize # use block_size instead diff --git a/tests/stubtest_allowlists/win32.txt b/tests/stubtest_allowlists/win32.txt index 216b99aad203..67141687bdcf 100644 --- a/tests/stubtest_allowlists/win32.txt +++ b/tests/stubtest_allowlists/win32.txt @@ -37,10 +37,6 @@ _ctypes.set_last_error # Allowlist entries that cannot or should not be fixed # ========== -# Aliases for OSError -builtins.WindowsError.characters_written -winreg.error.characters_written - # Modules that do not exist on Windows systems _curses _posixsubprocess diff --git a/tests/utils.py b/tests/utils.py index 4237ef6e13ac..5560dd932f61 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -17,7 +17,7 @@ def strip_comments(text: str) -> str: from termcolor import colored as colored except ImportError: - def colored(s: str, _: str) -> str: # type: ignore + def colored(s: str, _: str) -> str: # type: ignore[misc] return s