diff --git a/requirements-tests.txt b/requirements-tests.txt index 33e178325cf0..c629a619c4c4 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -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" diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index b5566a2ad8d1..a4e1425fc99b 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -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 diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index 8ddbb8fe3089..f1dd2471203e 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -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__ diff --git a/stubs/flake8/@tests/stubtest_allowlist.txt b/stubs/flake8/@tests/stubtest_allowlist.txt index c65acf1ff247..e33caad65504 100644 --- a/stubs/flake8/@tests/stubtest_allowlist.txt +++ b/stubs/flake8/@tests/stubtest_allowlist.txt @@ -1,4 +1 @@ flake8.__main__ - -# Can't reconcile @cached_property with @property. -flake8.processor.FileProcessor.file_tokens diff --git a/stubs/networkx/@tests/stubtest_allowlist.txt b/stubs/networkx/@tests/stubtest_allowlist.txt index 7db1c45f949a..b297bf9b2153 100644 --- a/stubs/networkx/@tests/stubtest_allowlist.txt +++ b/stubs/networkx/@tests/stubtest_allowlist.txt @@ -30,10 +30,3 @@ networkx\.algorithms\.bipartite\.(cluster\.)?clustering # failing to account for explicitly passing in the default value." # Which is true, but would require some way of concatenating `backend` to ParamSpec.kwargs networkx\.(utils\.)?(backends\.)?_dispatchable\.__call__ - -# TODO: stubtest does not like @cached_property https://github.com/python/mypy/issues/17625 -# "is inconsistent, cannot reconcile @property on stub with runtime object" -networkx(\.classes(\.graph)?)?\.Graph\.(adj|degree|edges|nodes) -networkx(\.classes(\.multigraph)?)?\.MultiGraph\.(adj|degree|edges) -networkx(\.classes(\.digraph)?)?\.DiGraph\.(adj|degree|edges|in_degree|in_edges|out_degree|out_edges|pred|succ) -networkx(\.classes(\.multidigraph)?)?\.MultiDiGraph\.(adj|degree|edges|in_degree|in_edges|out_degree|out_edges|pred|succ) diff --git a/stubs/openpyxl/@tests/test_cases/check_base_descriptors.py b/stubs/openpyxl/@tests/test_cases/check_base_descriptors.py index ecf8ec25ebe4..3dcbdc337228 100644 --- a/stubs/openpyxl/@tests/test_cases/check_base_descriptors.py +++ b/stubs/openpyxl/@tests/test_cases/check_base_descriptors.py @@ -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 @@ -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 @@ -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 = "" @@ -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 @@ -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 @@ -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 diff --git a/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py b/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py index 6db00a7adf92..301d519f03f1 100644 --- a/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py +++ b/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py @@ -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 @@ -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], _ ) @@ -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 @@ -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 diff --git a/stubs/pygit2/@tests/stubtest_allowlist.txt b/stubs/pygit2/@tests/stubtest_allowlist.txt index e7b6de1d313a..6c4060d50b4e 100644 --- a/stubs/pygit2/@tests/stubtest_allowlist.txt +++ b/stubs/pygit2/@tests/stubtest_allowlist.txt @@ -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__