Bump mypy to 1.0 (#9684)

This commit is contained in:
Alex Waygood
2023-02-06 23:57:17 +00:00
committed by GitHub
parent f7cb7f33b2
commit efee70abfa
37 changed files with 45 additions and 167 deletions

View File

@@ -5,7 +5,7 @@ flake8-bugbear==23.1.20; python_version >= "3.8" # must match .pre-commit-confi
flake8-noqa==1.3.0; python_version >= "3.8" # must match .pre-commit-config.yaml
flake8-pyi==23.1.2; python_version >= "3.8" # must match .pre-commit-config.yaml
isort==5.12.0; python_version >= "3.8" # must match .pre-commit-config.yaml
mypy==0.991
mypy==1.0
packaging==23.0
pathspec>=0.10.3
pre-commit-hooks==4.4.0 # must match .pre-commit-config.yaml

View File

@@ -65,4 +65,9 @@ if sys.platform == "darwin":
def open(self, url: str, new: int = 0, autoraise: bool = True) -> bool: ...
class MacOSXOSAScript(BaseBrowser): # In runtime this class does not have `name` and `basename`
if sys.version_info >= (3, 11):
def __init__(self, name: str = "default") -> None: ...
else:
def __init__(self, name: str) -> None: ...
def open(self, url: str, new: int = 0, autoraise: bool = True) -> bool: ...

View File

@@ -1,10 +1,2 @@
# Stub-only module.
exifread._types
# The following constants are only re-exported at runtime as a side effect
# of Python's import system.
exifread.DEFAULT_STOP_TAG
exifread.classes.DEFAULT_STOP_TAG
exifread.classes.EXIF_TAGS
exifread.classes.FIELD_TYPES
exifread.classes.IGNORE_TAGS

View File

@@ -0,0 +1,2 @@
# temp variable used to define scrotExists by checking if the command "scrot" exists
pyscreeze.whichProc

View File

@@ -2,10 +2,3 @@
cffi.(api.)?FFI.CData
cffi.(api.)?FFI.CType
cffi.(api.)?FFI.buffer
# Exists at runtime, but missing from stubs
cffi.vengine_cpy.__warningregistry__
# Unnecessary re-exports
cffi.cparser.COMMON_TYPES
cffi.verifier.__version_verifier_modules__

View File

@@ -1,3 +0,0 @@
# These are re-exports which we consider an implementation detail:
chevron.main.version
chevron.renderer.linesep

View File

@@ -42,8 +42,5 @@ colorama.ansi.AnsiStyle.RESET_ALL
colorama.initialise.wrapped_stderr
colorama.initialise.wrapped_stdout
# These are re-exports that are implementation detail:
colorama.ansitowin32.BEL
# Not planning on writing stubs for tests:
colorama.tests.*

View File

@@ -3,6 +3,5 @@ colorama.winterm.WinColor
colorama.winterm.WinStyle
colorama.winterm.WinTerm
# These are re-exports that are implementation detail:
colorama.ansitowin32.windll
# A re-export that's an implementation detail:
colorama.winterm.get_osfhandle

View File

@@ -6,13 +6,3 @@ dateparser.search.detection.BaseLanguageDetector.iterate_applicable_languages
# Timezone and other internal data:
dateparser.data.date_translation_data.*
# Re-exports:
dateparser.conf.date_order_chart
dateparser.conf.language_order
dateparser.languages.loader.language_locale_dict
dateparser.languages.loader.language_order
dateparser.languages.locale.ALWAYS_KEEP_TOKENS
dateparser.custom_language_detection.language_mapping.language_map
dateparser.custom_language_detection.fasttext.dateparser_model_home
dateparser.timezone_parser.timezone_info_list

View File

@@ -1,3 +0,0 @@
# These are re-exports which we consider an implementation detail
dockerfile_parse.parser.DOCKERFILE_FILENAME
dockerfile_parse.parser.COMMENT_INSTRUCTION

View File

@@ -2,13 +2,6 @@
fpdf.FPDF.output
fpdf.fpdf.FPDF.output
# Unnecessary re-export from codecs
fpdf.syntax.BOM_UTF16_BE
# stubtest doesn't recognize ImportError handler
fpdf.linearization.signer
fpdf.output.signer
# Argument has default at runtime, but using it raises a TypeError.
fpdf.FPDF.set_creation_date
fpdf.fpdf.FPDF.set_creation_date

View File

@@ -1,9 +1,2 @@
# Imports that stubtest thinks should be re-exported.
influxdb_client.client.write.dataframe_serializer.DEFAULT_WRITE_PRECISION
influxdb_client.client.write.retry.random
influxdb_client.client.write_api.DEFAULT_WRITE_PRECISION
influxdb_client.client.write_api.random
influxdb_client.client.write_api_async.DEFAULT_WRITE_PRECISION
# Metaclass problem inherited from urllib3.
influxdb_client.client.write.retry.WritesRetry

View File

@@ -2,15 +2,6 @@
# =============================
netaddr.core.a # This is a temporary module attribute used to detect python version
# These are unnecessary re-exports
netaddr.ip.INET_PTON
netaddr.ip.N
netaddr.ip.NOHOST
netaddr.ip.P
netaddr.ip.Z
netaddr.ip.ZEROFILL
# Error: is not present at runtime
# ================================
netaddr.ip.iana.XMLRecordParser.__getattr__ # __init__ has `self.__dict__.update(kwargs)`

View File

@@ -42,5 +42,5 @@ def clamp_value(minimum: int, val: int, maximum: int) -> int: ...
# This function attempts to convert objects to bytes,
# *but* just returns the object unchanged if that was unsuccessful!
def asbytes(s: object) -> object: ...
def b(s: str | bytes, encoding: str = "utf-8") -> bytes: ...
def u(s: str | bytes, encoding: str = "utf-8") -> str: ...
def b(s: str | bytes, encoding: str = "utf8") -> bytes: ...
def u(s: str | bytes, encoding: str = "utf8") -> str: ...

View File

@@ -1,8 +1,5 @@
parsimonious.nodes.RuleDecoratorMeta.__new__
# Re-export:
parsimonious.nodes.version_info
# Magic:
parsimonious.adhoc_expression

View File

@@ -37,15 +37,12 @@ passlib.utils.handlers.HasRounds.rounds
# Errors in `__all__` at runtime:
# TODO: change after https://github.com/python/mypy/pull/14217 is released
passlib.handlers.oracle
passlib.handlers.oracle.__all__
passlib.handlers.oracle.oracle11g
passlib.handlers.oracle.oracle10g
passlib.handlers.mysql
passlib.handlers.mysql.__all__
passlib.handlers.mysql.mysq41
# Mutable state because of the warnigns:
passlib.utils.des.__warningregistry__
# Compat tools are ignored:
passlib.utils.compat.*

View File

@@ -25,12 +25,6 @@ pika.adapters.blocking_connection.BlockingConnection.publisher_confirms
# created instances unusable, so we require the arguments in the stub.
pika.spec.Queue.DeclareOk.__init__
# Flagged by stubtest for unknown reasons.
pika.data.PY2
pika.data.basestring
pika.spec.str_or_bytes
pika.validators.basestring
# Arguments have a sentinel default, which is not reflected in the stubs.
pika.ConnectionParameters.__init__
pika.connection.ConnectionParameters.__init__

View File

@@ -1,8 +1,3 @@
# Unintended re-exports
pyasn1.compat.binary.version_info
pyasn1.compat.octets.version_info
pyasn1.compat.string.version_info
# type_check_only
pyasn1.type.base.NoValue.plug

View File

@@ -1,5 +1,2 @@
# Re-export:
crontabs.X_OK
# stub does not have *args argument "args", but function doesn't actually accept positional args
crontab.CronTab.remove_all

View File

@@ -20,9 +20,5 @@ Xlib.protocol.rq.*.name
# Structs generate their attributes (@type_check_only)
Xlib.protocol.rq.Struct.__getattr__
# Iteration variable bleed into the global scope
# Iteration variable that bleeds into the global scope
Xlib.protocol.rq.c
# Re-exports from six
Xlib.ext.xinput.integer_types
Xlib.protocol.display.PY3
Xlib.protocol.rq.PY3

View File

@@ -8,36 +8,10 @@ requests.adapters.PoolManager.proxy_config
requests.adapters.PoolManager.urlopen
requests.adapters.Retry.DEFAULT
# Unnecessary re-exported constants from requests.compat
requests.adapters.basestring
requests.auth.basestring
requests.utils.basestring
requests.utils.integer_types
requests.models.basestring
# Unnecessary re-exported constant
# (you should access this as `requests.__version__` or `requests.__version__.__version__`,
# not `requests.help.requests_version`)
requests.help.requests_version
# No reason to access this re-exported constant from `requests.sessions` instead of from `requests.utils`
requests.sessions.DEFAULT_PORTS
# Unnecessary re-exports of third-party modules
requests.help.chardet
requests.help.cryptography
requests.help.pyopenssl
requests.help.OpenSSL
# Loop variables that leak into the global scope
requests.packages.mod
requests.packages.package
requests.packages.target
# Internal implementation details, not for public consumption
requests.charset_normalizer_version
requests.chardet_version
requests.utils.HEADER_VALIDATORS
# Metaclass differs:
requests.adapters.Retry

View File

@@ -29,3 +29,7 @@ pkg_resources.to_filename
# Only present if docutils is installed
setuptools._distutils.command.check.SilentReporter
# Discrepancy in the value of the default
# between setuptools's version of distutils and the stdlib distutils
setuptools._distutils.core.Command.announce

View File

@@ -1,2 +0,0 @@
# re-exports
toml.decoder.linesep

View File

@@ -7,16 +7,16 @@ vobject.base.VBase.__init__
vobject.win32tz
# dependencies
vobject.change_tz.PyICU
vobject.icalendar.Pytz
vobject.icalendar.pytz
# re-exports
vobject.hcalendar.CRLF
# python2 compat
vobject.base.basestring
vobject.base.str_
vobject.base.to_unicode
vobject.base.to_basestring
vobject.vcard.basestring
# implementation details that users shouldn't depend on
vobject.base.formatter
vobject.base.handler

View File

@@ -24,33 +24,44 @@ class Change(NamedTuple):
hunk: int
file_timestamp_str: str
diffcmd_header: Pattern[str]
unified_header_index: Pattern[str]
unified_header_old_line: Pattern[str]
unified_header_new_line: Pattern[str]
unified_hunk_start: Pattern[str]
unified_change: Pattern[str]
context_header_old_line: Pattern[str]
context_header_new_line: Pattern[str]
context_hunk_start: Pattern[str]
context_hunk_old: Pattern[str]
context_hunk_new: Pattern[str]
context_change: Pattern[str]
ed_hunk_start: Pattern[str]
ed_hunk_end: Pattern[str]
rcs_ed_hunk_start: Pattern[str]
default_hunk_start: Pattern[str]
default_hunk_mid: Pattern[str]
default_change: Pattern[str]
git_diffcmd_header: Pattern[str]
git_header_index: Pattern[str]
git_header_old_line: Pattern[str]
git_header_new_line: Pattern[str]
git_header_file_mode: Pattern[str]
git_header_binary_file: Pattern[str]
git_binary_patch_start: Pattern[str]
git_binary_literal_start: Pattern[str]
git_binary_delta_start: Pattern[str]
base85string: Pattern[str]
bzr_header_index: Pattern[str]
bzr_header_old_line: Pattern[str]
bzr_header_new_line: Pattern[str]
svn_header_index: Pattern[str]
svn_header_timestamp_version: Pattern[str]
svn_header_timestamp: Pattern[str]

View File

@@ -1,5 +1 @@
zxcvbn.__main__
# re-exports:
zxcvbn.scoring.ADJACENCY_GRAPHS
zxcvbn.matching.FREQUENCY_LISTS

View File

@@ -1,5 +1,4 @@
_?curses.color_pair
webbrowser.MacOSXOSAScript.__init__
# Github Actions on macOS with Python 3.10.5 claims these are missing, but they do exist locally
(locale.bind_textdomain_codeset)?

View File

@@ -1,6 +1,5 @@
ctypes.wintypes
pwd.getpwnam
webbrowser.MacOSXOSAScript.__init__
# ==========
# Allowlist entries that cannot or should not be fixed

View File

@@ -1,5 +1,3 @@
webbrowser.MacOSXOSAScript.__init__
# ==========
# Allowlist entries that cannot or should not be fixed
# ==========

View File

@@ -1,5 +1,3 @@
webbrowser.MacOSXOSAScript.__init__
# ==========
# Allowlist entries that cannot or should not be fixed
# ==========

View File

@@ -84,7 +84,6 @@ _collections_abc.Iterable.__class_getitem__
_collections_abc.MappingView.__class_getitem__
_csv.Reader
_csv.Writer
asynchat.__warningregistry__ # Removal planned for 3.12, can add if someone needs this
bdb.Breakpoint.clearBreakpoints
distutils.util.get_host_platform
inspect.Signature.from_builtin # Removed in 3.11, can add if someone needs this

View File

@@ -13,10 +13,9 @@ _collections_abc.ValuesView.__reversed__
_csv.Reader
_csv.Writer
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__
# TODO: The stub for enum is nothing like the implementation
# TODO: The stub for enum.auto is nothing like the implementation
enum.auto.__init__
enum.auto.value
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve

View File

@@ -67,6 +67,10 @@ tempfile.SpooledTemporaryFile.readable
tempfile.SpooledTemporaryFile.seekable
tempfile.SpooledTemporaryFile.writable
# Default values given in the stub are a white lie, see #9637
tkinter.Tcl
tkinter.Tk.__init__
# Exists at runtime, but missing from stubs
contextvars.ContextVar.__class_getitem__
datetime.datetime_CAPI
@@ -76,7 +80,6 @@ distutils.cygwinccompiler.RE_VERSION
distutils.dist.command_re
distutils.fancy_getopt.longopt_re
distutils.fancy_getopt.neg_alias_re
distutils.core.DEBUG
distutils.core.USAGE
distutils.core.extension_keywords
distutils.core.gen_usage
@@ -91,7 +94,6 @@ ssl.OP_ENABLE_MIDDLEBOX_COMPAT
ssl.Options.OP_ENABLE_MIDDLEBOX_COMPAT
ssl.SSLObject.verify_client_post_handshake
ssl.SSLSocket.verify_client_post_handshake
stringprep.unicodedata # re-exported from unicodedata
tempfile.SpooledTemporaryFile.softspace
tkinter.Tk.split
tkinter.commondialog.[A-Z_]+
@@ -156,7 +158,6 @@ types.FunctionType.__get__
types.LambdaType.__get__
# Missing from distutils (deprecated, to be removed in 3.12)
distutils.core.DEBUG
distutils.core.USAGE
distutils.core.extension_keywords
distutils.core.gen_usage
@@ -184,7 +185,6 @@ distutils.core.Distribution.parse_command_line
distutils.core.Distribution.print_command_list
distutils.core.Distribution.reinitialize_command
distutils.core.Distribution.run_commands
distutils.cygwinccompiler.PIPE
distutils.cygwinccompiler.is_cygwingcc
distutils.dist.Distribution.announce
distutils.dist.Distribution.common_usage

View File

@@ -34,7 +34,6 @@ collections.KeysView.__reversed__
collections.ValuesView.__reversed__
collections.Mapping.__reversed__ # Set to None at runtime for a better error message
distutils.command.bdist_wininst # see #6523
distutils.core.DEBUG
distutils.core.USAGE
distutils.core.extension_keywords
distutils.core.gen_usage
@@ -89,6 +88,10 @@ tempfile.SpooledTemporaryFile.readable
tempfile.SpooledTemporaryFile.seekable
tempfile.SpooledTemporaryFile.writable
# Default values given in the stub are a white lie, see #9637
tkinter.Tcl
tkinter.Tk.__init__
# Exists at runtime, but missing from stubs
contextvars.ContextVar.__class_getitem__
datetime.datetime_CAPI
@@ -111,7 +114,6 @@ multiprocessing.managers.SharedMemoryServer.shutdown
multiprocessing.managers.SharedMemoryServer.track_segment
plistlib.Data.asBase64
plistlib.Data.fromBase64
stringprep.unicodedata # re-exported from unicodedata
tempfile.SpooledTemporaryFile.softspace
tkinter.Tk.split
tkinter.commondialog.[A-Z_]+
@@ -173,7 +175,6 @@ types.FunctionType.__get__
types.LambdaType.__get__
# Missing from distutils (deprecated, to be removed in 3.12)
distutils.core.DEBUG
distutils.core.USAGE
distutils.core.extension_keywords
distutils.core.gen_usage
@@ -201,7 +202,6 @@ distutils.core.Distribution.parse_command_line
distutils.core.Distribution.print_command_list
distutils.core.Distribution.reinitialize_command
distutils.core.Distribution.run_commands
distutils.cygwinccompiler.PIPE
distutils.cygwinccompiler.is_cygwingcc
distutils.dist.Distribution.announce
distutils.dist.Distribution.common_usage

View File

@@ -34,7 +34,6 @@ collections.ValuesView.__reversed__
contextlib.AbstractAsyncContextManager.__class_getitem__
contextlib.AbstractContextManager.__class_getitem__
distutils.command.bdist_wininst # see #6523
distutils.core.DEBUG
distutils.core.USAGE
distutils.core.extension_keywords
distutils.core.gen_usage
@@ -112,7 +111,6 @@ multiprocessing.managers.SharedMemoryServer.public
multiprocessing.managers.SharedMemoryServer.release_segment
multiprocessing.managers.SharedMemoryServer.shutdown
multiprocessing.managers.SharedMemoryServer.track_segment
stringprep.unicodedata # re-exported from unicodedata
types.GenericAlias.__mro_entries__
typing._SpecialForm.__mro_entries__
@@ -172,7 +170,6 @@ types.FunctionType.__get__
types.LambdaType.__get__
# Missing from distutils (deprecated, to be removed in 3.12)
distutils.core.DEBUG
distutils.core.USAGE
distutils.core.extension_keywords
distutils.core.gen_usage
@@ -200,7 +197,6 @@ distutils.core.Distribution.parse_command_line
distutils.core.Distribution.print_command_list
distutils.core.Distribution.reinitialize_command
distutils.core.Distribution.run_commands
distutils.cygwinccompiler.PIPE
distutils.cygwinccompiler.is_cygwingcc
distutils.dist.Distribution.announce
distutils.dist.Distribution.common_usage

View File

@@ -30,6 +30,7 @@ _weakref.CallableProxyType.__getattr__ # Should have all attributes of proxy
_weakref.ProxyType.__getattr__ # Should have all attributes of proxy
_weakref.ReferenceType.__call__ # C function default annotation is wrong
_weakref.ReferenceType.__init__ # Runtime defines __new__ but stubtest thinks __init__ is also defined.
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
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
@@ -132,7 +133,7 @@ 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)?
(locale.__all__)?
multiprocessing.JoinableQueue
multiprocessing.Queue
multiprocessing.SimpleQueue
@@ -493,17 +494,7 @@ turtle.ScrolledCanvas.find_all
turtle.ScrolledCanvas.select_clear
turtle.ScrolledCanvas.select_item
# Unnecessary re-exports
asyncore\.E[A-Z]+ # re-exported from errno
asyncore.errorcode # re-exported from errno
email._header_value_parser.hexdigits
logging.handlers.ST_[A-Z]+
xml.dom.expatbuilder.EMPTY_NAMESPACE
xml.dom.expatbuilder.EMPTY_PREFIX
xml.dom.expatbuilder.XMLNS_NAMESPACE
xml.dom.minidom.EMPTY_NAMESPACE
xml.dom.minidom.EMPTY_PREFIX
xml.dom.minidom.XMLNS_NAMESPACE
# Unnecessary re-export
xml.dom.minidom.StringTypes
# __all__-related weirdness (see #6523)
@@ -655,11 +646,7 @@ distutils.ccompiler.compiler_class
distutils.cmd.Command.dump_options
distutils.cmd.Command.ensure_finalized
distutils.command.bdist
distutils.command.bdist_rpm.DEBUG
distutils.command.build_ext.USER_BASE
distutils.command.build_scripts.ST_MODE
distutils.command.install.*
distutils.command.install_scripts.ST_MODE
distutils.core.Distribution.finalize_options
distutils.core.Distribution.get_command_class
distutils.core.Distribution.get_command_list
@@ -681,7 +668,6 @@ distutils.cygwinccompiler.check_config_h
distutils.cygwinccompiler.get_msvcr
distutils.cygwinccompiler.get_versions
distutils.dir_util.ensure_relative
distutils.dist.DEBUG
distutils.dist.Distribution.finalize_options
distutils.dist.Distribution.get_command_class
distutils.dist.Distribution.get_command_list
@@ -722,7 +708,6 @@ distutils.msvccompiler.get_build_version
distutils.msvccompiler.normalize_and_reduce_paths
distutils.msvccompiler.read_keys
distutils.msvccompiler.read_values
distutils.spawn.DEBUG
distutils.sysconfig.BASE_EXEC_PREFIX
distutils.sysconfig.BASE_PREFIX
distutils.sysconfig.build_flags

View File

@@ -1,6 +1,4 @@
ctypes.GetLastError # Is actually a pointer
distutils.archive_util.getgrnam
distutils.archive_util.getpwnam
distutils.msvccompiler.HKEYS
locale.[A-Z0-9_]+ # Constants that should be moved to _locale and re-exported conditionally
locale.nl_langinfo # Function that should be moved to _locale and re-exported conditionally
@@ -14,7 +12,6 @@ selectors.KqueueSelector
signal.SIGEMT
signal.SIGINFO
winsound.SND_APPLICATION
xmlrpc.server.fcntl
# Exists at runtime, but missing from stubs
_msi.MSIError