Bump mypy to 0.981 (#8796)

This commit is contained in:
Alex Waygood
2022-09-27 01:14:33 +01:00
committed by GitHub
parent 9abe56a19a
commit 48e76e8a56
29 changed files with 23 additions and 185 deletions

View File

@@ -13,7 +13,7 @@ from dataclasses import dataclass
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

View File

@@ -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")])

View File

@@ -35,8 +35,6 @@ _ctypes.dlopen
_ctypes.dlsym
posix.NGROUPS_MAX
posix.error.characters_written
resource.error.characters_written
select.POLLRDHUP
webbrowser.MacOSX.__init__

View File

@@ -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_]+

View File

@@ -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

View File

@@ -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\..*

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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

View File

@@ -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

View File

@@ -17,7 +17,7 @@ try:
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