Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 7 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies = []

[dependency-groups]
numpy = ["numtype[numpy]"]
lint = ["ruff>=0.11.10"]
lint = ["ruff>=0.11.12"]
pytest = [
{include-group = "numpy"},
"pytest>=8.3.5",
Expand All @@ -60,17 +60,17 @@ list_and_test = [
]
types = [
{include-group = "pytest"},
"types-setuptools>=80.7.0.20250516",
"types-setuptools>=80.9.0.20250529",
"types-tabulate>=0.9.0.20241207",
]
basedpyright = [
{include-group = "numpy"},
{include-group = "types"},
"basedpyright>=1.29.1",
"basedpyright>=1.29.2",
]
mypy = [
{include-group = "types"},
"mypy[faster-cache]>=1.15.0",
"mypy[faster-cache]>=1.16.0",
]
typecheck = [
{include-group = "basedpyright"},
Expand Down Expand Up @@ -111,23 +111,12 @@ skip-excluded-dirs = true
[tool.mypy]
mypy_path = "src"
strict = true
strict_bytes = true
strict_concatenate = true
local_partial_types = true
enable_error_code = ["ignore-without-code", "truthy-bool"]
disable_error_code = ["explicit-override"]
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
enable_incomplete_feature = ["PreciseTupleTypes"]
disallow_any_explicit = false
disallow_any_expr = false
disallow_any_decorated = false
allow_redefinition_new = true
local_partial_types = true
warn_incomplete_stub = true
warn_unreachable = false
# needed for stubtest, see https://github.com/python/mypy/issues/18744
disable_bytearray_promotion = true
disable_memoryview_promotion = true
# basedmypy/mypy compat
# bare_literals = false
# default_return = false


[tool.pyright]
Expand Down
2 changes: 1 addition & 1 deletion src/numpy-stubs/@test/static/accept/testing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ assert_type(np.testing.clear_and_catch_warnings.modules, set[types.ModuleType])

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

assert_type(np.testing.suppress_warnings("once"), np.testing.suppress_warnings)
Expand Down
2 changes: 1 addition & 1 deletion src/numpy-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4785,7 +4785,7 @@ class complex64(complexfloating):

csingle = complex64

class complex128(complexfloating, complex): # type: ignore[misc]
class complex128(complexfloating, complex):
#
@overload
def __new__(cls, real: _ConvertibleToComplex | None = 0, /) -> Self: ...
Expand Down
2 changes: 1 addition & 1 deletion src/numpy-stubs/ma/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ class MaskedArray(np.ndarray[_ShapeT_co, _DTypeT_co]):

#
@override
def ptp( # type: ignore[override] # pyright: ignore[reportIncompatibleVariableOverride]
def ptp( # pyright: ignore[reportIncompatibleVariableOverride]
self, axis: Incomplete = ..., out: Incomplete = ..., fill_value: Incomplete = ..., keepdims: Incomplete = ...
) -> Incomplete: ...

Expand Down
2 changes: 1 addition & 1 deletion src/numpy-stubs/matrixlib/defmatrix.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class matrix(np.ndarray[_ShapeT_co, _DTypeT_co]):
def argmin(self, /, axis: _ToAxis | None = None, *, out: _ArrayT) -> _ArrayT: ... # pyright: ignore[reportIncompatibleMethodOverride]

#
@overload # type: ignore[override]
@overload
def ptp(self: _nt.Array[_ScalarT], /, axis: None = None, out: None = None) -> _ScalarT: ...
@overload
def ptp(self, /, axis: _ToAxis, out: None = None) -> matrix[_nt.Rank2, _DTypeT_co]: ...
Expand Down
2 changes: 1 addition & 1 deletion src/numpy-stubs/testing/_private/utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class KnownFailureException(Exception): ...
class IgnoreException(Exception): ...

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

Expand Down
3 changes: 0 additions & 3 deletions tool/allowlists/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,5 @@ numpy\.f2py\.__main__
# does not exist
numpy\.distutils\.\w+

# workaround for https://github.com/python/mypy/issues/15302#issuecomment-2701979355
numpy\.testing(\._private\.utils)?\.check_support_sve

# stdlib re-exports with incorrect typeshed stubs
numpy\.compat(\.py3k)?\.os_PathLike\.__class_getitem__
7 changes: 0 additions & 7 deletions tool/allowlists/path-py311.txt

This file was deleted.

5 changes: 0 additions & 5 deletions tool/allowlists/path-py312.txt

This file was deleted.

30 changes: 1 addition & 29 deletions tool/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# requires-python = ">=3.11"
# dependencies = [
# "numtype[numpy]",
# "mypy[faster-cache]>=1.15.0", # keep in sync with pyproject.toml
# "mypy[faster-cache]>=1.16.0", # keep in sync with pyproject.toml
#
# "PyInstaller",
# "hypothesis",
Expand Down Expand Up @@ -49,12 +49,6 @@
("ge" if sys.version_info >= (3, 12) else "lt") + "-py312.txt",
]

if sys.platform == "win32":
if sys.version_info[:2] == (3, 12):
ALLOWLISTS.append("path-py312.txt")
elif sys.version_info[:2] <= (3, 11):
ALLOWLISTS.append("path-py311.txt")


def __check_simd() -> None:
try:
Expand All @@ -69,26 +63,6 @@ def __check_simd() -> None:
__check_simd()


def __commit_pyi_genocide_for_mypy() -> None:
"""
Remove all ``__init__.pyi`` files from the installed numpy package.

This works around https://github.com/python/mypy/issues/18997 on `mypy<1.16.0`.

Raises
------
NotADirectoryError
If `numpy` does not exist in the site-packages.
"""
package = SITE_DIR / "numpy"
if not package.is_dir():
raise NotADirectoryError(f"{package} does not exist")

graveyard_size = sum(not pyi.unlink() for pyi in package.rglob("__init__.pyi")) # type: ignore[func-returns-value]
if VERBOSE and graveyard_size:
print(f"deleted {graveyard_size} __init__.pyi from {package}\n")


def _allowlists() -> list[str]:
relpath = (TOOL_DIR / "allowlists").relative_to(CWD)
return [str(relpath / fname) for fname in ALLOWLISTS]
Expand Down Expand Up @@ -147,8 +121,6 @@ def main() -> int:
-------
exit_code : int
"""
__commit_pyi_genocide_for_mypy()

if VERBOSE:
import numpy as np # noqa: PLC0415
import numtype as nt # noqa: PLC0415
Expand Down
Loading