Skip to content

Commit 83c2f49

Browse files
authored
Merge pull request #577 from numpy/mypy-1.16.0
2 parents 9ef9d86 + 450b4cb commit 83c2f49

File tree

13 files changed

+168
-211
lines changed

13 files changed

+168
-211
lines changed

pyproject.toml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dependencies = []
4848

4949
[dependency-groups]
5050
numpy = ["numtype[numpy]"]
51-
lint = ["ruff>=0.11.10"]
51+
lint = ["ruff>=0.11.12"]
5252
pytest = [
5353
{include-group = "numpy"},
5454
"pytest>=8.3.5",
@@ -60,17 +60,17 @@ list_and_test = [
6060
]
6161
types = [
6262
{include-group = "pytest"},
63-
"types-setuptools>=80.7.0.20250516",
63+
"types-setuptools>=80.9.0.20250529",
6464
"types-tabulate>=0.9.0.20241207",
6565
]
6666
basedpyright = [
6767
{include-group = "numpy"},
6868
{include-group = "types"},
69-
"basedpyright>=1.29.1",
69+
"basedpyright>=1.29.2",
7070
]
7171
mypy = [
7272
{include-group = "types"},
73-
"mypy[faster-cache]>=1.15.0",
73+
"mypy[faster-cache]>=1.16.0",
7474
]
7575
typecheck = [
7676
{include-group = "basedpyright"},
@@ -111,23 +111,12 @@ skip-excluded-dirs = true
111111
[tool.mypy]
112112
mypy_path = "src"
113113
strict = true
114-
strict_bytes = true
115-
strict_concatenate = true
116-
local_partial_types = true
117-
enable_error_code = ["ignore-without-code", "truthy-bool"]
118-
disable_error_code = ["explicit-override"]
114+
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
119115
enable_incomplete_feature = ["PreciseTupleTypes"]
120-
disallow_any_explicit = false
121-
disallow_any_expr = false
122-
disallow_any_decorated = false
116+
allow_redefinition_new = true
117+
local_partial_types = true
123118
warn_incomplete_stub = true
124119
warn_unreachable = false
125-
# needed for stubtest, see https://github.com/python/mypy/issues/18744
126-
disable_bytearray_promotion = true
127-
disable_memoryview_promotion = true
128-
# basedmypy/mypy compat
129-
# bare_literals = false
130-
# default_return = false
131120

132121

133122
[tool.pyright]

src/numpy-stubs/@test/static/accept/testing.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ assert_type(np.testing.clear_and_catch_warnings.modules, set[types.ModuleType])
4343

4444
with np.testing.clear_and_catch_warnings(True) as c1:
4545
assert_type(c1, list[warnings.WarningMessage])
46-
with np.testing.clear_and_catch_warnings() as c2: # type: ignore[var-annotated]
46+
with np.testing.clear_and_catch_warnings() as c2:
4747
assert_type(c2, None)
4848

4949
assert_type(np.testing.suppress_warnings("once"), np.testing.suppress_warnings)

src/numpy-stubs/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4785,7 +4785,7 @@ class complex64(complexfloating):
47854785

47864786
csingle = complex64
47874787

4788-
class complex128(complexfloating, complex): # type: ignore[misc]
4788+
class complex128(complexfloating, complex):
47894789
#
47904790
@overload
47914791
def __new__(cls, real: _ConvertibleToComplex | None = 0, /) -> Self: ...

src/numpy-stubs/ma/core.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ class MaskedArray(np.ndarray[_ShapeT_co, _DTypeT_co]):
624624

625625
#
626626
@override
627-
def ptp( # type: ignore[override] # pyright: ignore[reportIncompatibleVariableOverride]
627+
def ptp( # pyright: ignore[reportIncompatibleVariableOverride]
628628
self, axis: Incomplete = ..., out: Incomplete = ..., fill_value: Incomplete = ..., keepdims: Incomplete = ...
629629
) -> Incomplete: ...
630630

src/numpy-stubs/matrixlib/defmatrix.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class matrix(np.ndarray[_ShapeT_co, _DTypeT_co]):
177177
def argmin(self, /, axis: _ToAxis | None = None, *, out: _ArrayT) -> _ArrayT: ... # pyright: ignore[reportIncompatibleMethodOverride]
178178

179179
#
180-
@overload # type: ignore[override]
180+
@overload
181181
def ptp(self: _nt.Array[_ScalarT], /, axis: None = None, out: None = None) -> _ScalarT: ...
182182
@overload
183183
def ptp(self, /, axis: _ToAxis, out: None = None) -> matrix[_nt.Rank2, _DTypeT_co]: ...

src/numpy-stubs/testing/_private/utils.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class KnownFailureException(Exception): ...
129129
class IgnoreException(Exception): ...
130130

131131
# NOTE: `warnings.catch_warnings` is incorrectly defined as invariant in typeshed
132-
class clear_and_catch_warnings(warnings.catch_warnings[_W_co], Generic[_W_co]): # type: ignore[type-var]
132+
class clear_and_catch_warnings(warnings.catch_warnings[_W_co], Generic[_W_co]):
133133
class_modules: ClassVar[tuple[types.ModuleType, ...]] = ()
134134
modules: Final[set[types.ModuleType]]
135135

tool/allowlists/common.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,5 @@ numpy\.f2py\.__main__
3434
# does not exist
3535
numpy\.distutils\.\w+
3636

37-
# workaround for https://github.com/python/mypy/issues/15302#issuecomment-2701979355
38-
numpy\.testing(\._private\.utils)?\.check_support_sve
39-
4037
# stdlib re-exports with incorrect typeshed stubs
4138
numpy\.compat(\.py3k)?\.os_PathLike\.__class_getitem__

tool/allowlists/path-py311.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

tool/allowlists/path-py312.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

tool/stubtest.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# requires-python = ">=3.11"
33
# dependencies = [
44
# "numtype[numpy]",
5-
# "mypy[faster-cache]>=1.15.0", # keep in sync with pyproject.toml
5+
# "mypy[faster-cache]>=1.16.0", # keep in sync with pyproject.toml
66
#
77
# "PyInstaller",
88
# "hypothesis",
@@ -49,12 +49,6 @@
4949
("ge" if sys.version_info >= (3, 12) else "lt") + "-py312.txt",
5050
]
5151

52-
if sys.platform == "win32":
53-
if sys.version_info[:2] == (3, 12):
54-
ALLOWLISTS.append("path-py312.txt")
55-
elif sys.version_info[:2] <= (3, 11):
56-
ALLOWLISTS.append("path-py311.txt")
57-
5852

5953
def __check_simd() -> None:
6054
try:
@@ -69,26 +63,6 @@ def __check_simd() -> None:
6963
__check_simd()
7064

7165

72-
def __commit_pyi_genocide_for_mypy() -> None:
73-
"""
74-
Remove all ``__init__.pyi`` files from the installed numpy package.
75-
76-
This works around https://github.com/python/mypy/issues/18997 on `mypy<1.16.0`.
77-
78-
Raises
79-
------
80-
NotADirectoryError
81-
If `numpy` does not exist in the site-packages.
82-
"""
83-
package = SITE_DIR / "numpy"
84-
if not package.is_dir():
85-
raise NotADirectoryError(f"{package} does not exist")
86-
87-
graveyard_size = sum(not pyi.unlink() for pyi in package.rglob("__init__.pyi")) # type: ignore[func-returns-value]
88-
if VERBOSE and graveyard_size:
89-
print(f"deleted {graveyard_size} __init__.pyi from {package}\n")
90-
91-
9266
def _allowlists() -> list[str]:
9367
relpath = (TOOL_DIR / "allowlists").relative_to(CWD)
9468
return [str(relpath / fname) for fname in ALLOWLISTS]
@@ -147,8 +121,6 @@ def main() -> int:
147121
-------
148122
exit_code : int
149123
"""
150-
__commit_pyi_genocide_for_mypy()
151-
152124
if VERBOSE:
153125
import numpy as np # noqa: PLC0415
154126
import numtype as nt # noqa: PLC0415

0 commit comments

Comments
 (0)