Skip to content
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

Update mypy to 1.12.0 #12859

Merged
merged 6 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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 requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Type checkers that we test our stubs against. These should always
# be pinned to a specific version to make failure reproducible.
mypy==1.11.2
mypy==1.12.0
pyright==1.1.385
# pytype can be installed on Windows, but requires building wheels, let's not do that on the CI
pytype==2024.10.11; platform_system != "Windows" and python_version >= "3.10" and python_version < "3.13"
Expand Down
2 changes: 0 additions & 2 deletions stdlib/@tests/stubtest_allowlists/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ _io.StringIO.truncate
_io.TextIOWrapper.truncate
ipaddress.IPv4Interface.hostmask
ipaddress.IPv6Interface.hostmask
ipaddress._BaseNetwork.broadcast_address
ipaddress._BaseNetwork.hostmask
ipaddress._BaseAddress.is_global
ipaddress._BaseAddress.is_link_local
ipaddress._BaseAddress.is_loopback
Expand Down
4 changes: 0 additions & 4 deletions stdlib/@tests/stubtest_allowlists/py313.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,3 @@ codecs.xmlcharrefreplace_errors

# To match `dict`, we lie about the runtime, but use overloads to match the correct behavior
types.MappingProxyType.get

# `__replace__` is dynamically generated, and special-cased by type-checkers
pstats.FunctionProfile.__replace__
pstats.StatsProfile.__replace__
14 changes: 7 additions & 7 deletions stubs/openpyxl/@tests/test_cases/check_base_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class WithDescriptorsStrict(Strict):
# Test getters
assert_type(with_descriptors.descriptor, str)

assert_type(with_descriptors.typed_not_none, str) # type: ignore[assert-type] # False-positive in mypy
assert_type(with_descriptors.typed_not_none, str)
assert_type(with_descriptors.typed_none, Union[str, None])

assert_type(with_descriptors.set_tuple, Union[Literal["a", 1], float]) # type: ignore[assert-type] # False-positive in mypy
Expand All @@ -172,9 +172,9 @@ class WithDescriptorsStrict(Strict):
assert_type(with_descriptors.length_tuple, Tuple[str, str])
assert_type(with_descriptors.length_list, List[str])

assert_type(with_descriptors.match_pattern_str, str) # type: ignore[assert-type] # False-positive in mypy
assert_type(with_descriptors.match_pattern_str, str)
assert_type(with_descriptors.match_pattern_str_none, Union[str, None])
assert_type(with_descriptors.match_pattern_bytes, ReadableBuffer) # type: ignore[assert-type] # False-positive in mypy
assert_type(with_descriptors.match_pattern_bytes, ReadableBuffer)
assert_type(with_descriptors.match_pattern_bytes_none, Union[ReadableBuffer, None])

assert_type(with_descriptors.convertible_not_none, int) # type: ignore[assert-type] # False-positive in mypy
Expand Down Expand Up @@ -208,7 +208,7 @@ class WithDescriptorsStrict(Strict):


with_descriptors.typed_not_none = ""
with_descriptors.typed_not_none = None # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.typed_not_none = None # type: ignore
with_descriptors.typed_not_none = 0 # type: ignore

with_descriptors.typed_none = ""
Expand Down Expand Up @@ -267,7 +267,7 @@ class WithDescriptorsStrict(Strict):


with_descriptors.match_pattern_str = ""
with_descriptors.match_pattern_str = None # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.match_pattern_str = None # type: ignore
with_descriptors.match_pattern_str = b"" # type: ignore
with_descriptors.match_pattern_str = 0 # type: ignore

Expand All @@ -277,7 +277,7 @@ class WithDescriptorsStrict(Strict):
with_descriptors.match_pattern_str_none = 0 # type: ignore

with_descriptors.match_pattern_bytes = b""
with_descriptors.match_pattern_bytes = None # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.match_pattern_bytes = None # type: ignore
with_descriptors.match_pattern_bytes = "" # type: ignore
with_descriptors.match_pattern_bytes = 0 # type: ignore

Expand Down Expand Up @@ -340,7 +340,7 @@ class WithDescriptorsStrict(Strict):

with_descriptors.datetime_not_none = datetime(0, 0, 0)
with_descriptors.datetime_not_none = ""
with_descriptors.datetime_not_none = None # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.datetime_not_none = None # type: ignore
with_descriptors.datetime_not_none = 0 # type: ignore
with_descriptors.datetime_not_none = date(0, 0, 0) # type: ignore
with_descriptors.datetime_not_none = time() # type: ignore
Expand Down
30 changes: 15 additions & 15 deletions stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,23 @@ class WithDescriptorsStrict(Strict):
assert_type(with_descriptors.noneset_tuple, Union[Literal["a", 1], float, None]) # type: ignore[assert-type] # False-positive in mypy
assert_type(with_descriptors.noneset_list, Union[str, float, None]) # type: ignore[assert-type] # False-positive in mypy # int and float are merged in generic unions

assert_type(with_descriptors.convertible_not_none, int) # type: ignore[assert-type] # False-positive in mypy
assert_type(with_descriptors.convertible_not_none, int)
assert_type(with_descriptors.convertible_none, Union[int, None])

assert_type(with_descriptors.text_str_not_none, str) # type: ignore[assert-type] # False-positive in mypy
assert_type(with_descriptors.text_str_not_none, str)
assert_type(with_descriptors.text_str_none, Union[str, None])
assert_type(with_descriptors.text_int_not_none, int) # type: ignore[assert-type] # False-positive in mypy
assert_type(with_descriptors.text_int_not_none, int)
assert_type(with_descriptors.text_int_none, Union[int, None])

assert_type(with_descriptors.minmax_float, float) # type: ignore[assert-type] # False-positive in mypy
assert_type(with_descriptors.minmax_float, float)
assert_type(with_descriptors.minmax_float_none, Union[float, None])
assert_type(with_descriptors.minmax_int, int) # type: ignore[assert-type] # False-positive in mypy
assert_type(with_descriptors.minmax_int, int)
assert_type(with_descriptors.minmax_int_none, Union[int, None])

assert_type(with_descriptors.bool_not_none, bool) # type: ignore[assert-type] # False-positive in mypy
assert_type(with_descriptors.bool_none, Union[bool, None])

assert_type(with_descriptors.emptytag_not_none, bool) # type: ignore[assert-type] # False-positive in mypy
assert_type(with_descriptors.emptytag_not_none, bool)
assert_type(with_descriptors.emptytag_none, Union[bool, None])

assert_type(with_descriptors.string_not_none, str) # type: ignore[assert-type] # False-positive in mypy
Expand Down Expand Up @@ -301,16 +301,16 @@ class WithDescriptorsStrict(Strict):

with_descriptors.text_int_not_none = 0
with_descriptors.text_int_not_none = "0"
with_descriptors.text_int_not_none = None # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.text_int_not_none = object() # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.text_int_not_none = None # type: ignore
with_descriptors.text_int_not_none = object() # type: ignore
# If expected type (_T) is not str, it's impossible to use an Element as the value
with_descriptors.text_int_not_none = cast( # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.text_int_not_none = cast( # type: ignore
_HasTagAndGet[int], _
)
with_descriptors.text_int_not_none = cast( # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.text_int_not_none = cast( # type: ignore
_HasTagAndGet[None], _
)
with_descriptors.text_int_not_none = cast( # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.text_int_not_none = cast( # type: ignore
_HasTagAndGet[str], _
)

Expand All @@ -333,10 +333,10 @@ class WithDescriptorsStrict(Strict):
with_descriptors.minmax_float = 0
with_descriptors.minmax_float = "0"
with_descriptors.minmax_float = 0.0
with_descriptors.minmax_float = None # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.minmax_float = None # type: ignore
with_descriptors.minmax_float = object() # type: ignore
with_descriptors.minmax_float = cast(_HasTagAndGet[float], _)
with_descriptors.minmax_float = cast( # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.minmax_float = cast( # type: ignore
_HasTagAndGet[None], _
)
with_descriptors.minmax_float = cast(_HasTagAndGet[object], _) # type: ignore
Expand All @@ -353,10 +353,10 @@ class WithDescriptorsStrict(Strict):
with_descriptors.minmax_int = 0
with_descriptors.minmax_int = "0"
with_descriptors.minmax_int = 0.0
with_descriptors.minmax_int = None # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.minmax_int = None # type: ignore
with_descriptors.minmax_int = object() # type: ignore
with_descriptors.minmax_int = cast(_HasTagAndGet[int], _)
with_descriptors.minmax_int = cast(_HasTagAndGet[None], _) # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
with_descriptors.minmax_int = cast(_HasTagAndGet[None], _) # type: ignore
with_descriptors.minmax_int = cast(_HasTagAndGet[object], _) # type: ignore

with_descriptors.minmax_int_none = 0
Expand Down
4 changes: 0 additions & 4 deletions stubs/pygit2/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# @cached_property that fail to get recognized as such by stubtest
pygit2.config.ConfigEntry.level
pygit2.config.ConfigEntry.raw_name
pygit2.config.ConfigEntry.raw_value
# Actual signatures enforced by C-level checks not visible to stubtest
pygit2.Mailmap.__init__
pygit2.OdbBackend.__init__
Expand Down
Loading