diff --git a/pyproject.toml b/pyproject.toml index 2c458b9a..4511f709 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,6 +90,8 @@ dev = [ { include-group = "docs" }, ] +# hatch + [tool.hatch.build] exclude = [ "**/@test", @@ -105,6 +107,8 @@ skip-excluded-dirs = true [tool.hatch.build.targets.wheel] packages = ["src/_numtype", "src/numtype", "src/numpy-stubs"] +# mypy + [tool.mypy] mypy_path = "src" strict = true @@ -115,6 +119,8 @@ local_partial_types = true warn_incomplete_stub = true warn_unreachable = false +# (based)pyright + [tool.pyright] include = ["src", "tool"] ignore = [".venv"] @@ -165,6 +171,8 @@ reportPrivateLocalImportUsage = true reportUnannotatedClassAttribute = false strictGenericNarrowing = true +# ruff + [tool.ruff] src = ["src", "tool"] extend-exclude = [".git", ".mypy_cache", ".tox", ".venv"] @@ -182,10 +190,8 @@ ignore = ["CPY", "FIX002", "COM812"] [tool.ruff.lint.per-file-ignores] "*.pyi" = [ - "N", # pep8-naming "TD", # flake8-todo - "COM812", # flake8-commas: missing-trailing-comma - "PLC2701", # pylint/convention: import-private-name + # "PLC2701", # pylint/convention: import-private-name ] [tool.ruff.lint.flake8-builtins] @@ -224,6 +230,8 @@ convention = "numpy" [tool.ruff.lint.pylint] allow-dunder-method-names = ["__array__", "__array_ufunc__"] +# pytest + [tool.pytest.ini_options] minversion = "8.0" addopts = ["-ra", "--strict-config", "--strict-markers"] @@ -231,9 +239,10 @@ filterwarnings = ["error"] log_cli_level = "INFO" xfail_strict = true -# install tox with `uv tool install tox --with tox-uv --upgrade` -# and run with `uvx tox p` +# tox + [tool.tox] +# install with `uv tool install tox --with tox-uv --upgrade` and run with `uvx tox p` min_version = "4" requires = ["tox-uv>=1"] env_list = [ @@ -295,6 +304,8 @@ commands = [ ], ] +# typos + [tool.typos] [tool.typos.default] diff --git a/src/_numtype/@test/test_can_array_0d.pyi b/src/_numtype/@test/test_can_array_0d.pyi index 217047a9..57a8248d 100644 --- a/src/_numtype/@test/test_can_array_0d.pyi +++ b/src/_numtype/@test/test_can_array_0d.pyi @@ -20,9 +20,9 @@ can_ld_0d: _nt.CanArray0D[np.longdouble] = np.longdouble() can_c8_0d: _nt.CanArray0D[np.complex64] = np.complex64() can_c16_0d: _nt.CanArray0D[np.complex128] = np.complex128() can_cld_0d: _nt.CanArray0D[np.clongdouble] = np.clongdouble() -can_O_0d: _nt.CanArray0D[np.object_] = np.empty((), np.object_) -can_M_0d: _nt.CanArray0D[np.datetime64] = np.datetime64(None) -can_m_0d: _nt.CanArray0D[np.timedelta64] = np.timedelta64(None) -can_S_0d: _nt.CanArray0D[np.bytes_] = np.bytes_(b"") -can_U_0d: _nt.CanArray0D[np.str_] = np.str_("") -can_V_0d: _nt.CanArray0D[np.void] = np.void(b"") +can_obj_0d: _nt.CanArray0D[np.object_] = np.empty((), np.object_) +can_dt_0d: _nt.CanArray0D[np.datetime64] = np.datetime64(None) +can_td_0d: _nt.CanArray0D[np.timedelta64] = np.timedelta64(None) +can_bytes_0d: _nt.CanArray0D[np.bytes_] = np.bytes_(b"") +can_str_0d: _nt.CanArray0D[np.str_] = np.str_("") +can_void_0d: _nt.CanArray0D[np.void] = np.void(b"") diff --git a/src/_numtype/@test/test_rank_shape.pyi b/src/_numtype/@test/test_rank_shape.pyi index 6cf950dd..59cd14b7 100644 --- a/src/_numtype/@test/test_rank_shape.pyi +++ b/src/_numtype/@test/test_rank_shape.pyi @@ -1,6 +1,6 @@ from typing import assert_type -import _numtype as _nt +import _numtype as _nt # noqa: PLC2701 # TODO: remove the `# type: ignore`s once python/mypy#19110 is fixed diff --git a/src/_numtype/__init__.pyi b/src/_numtype/__init__.pyi index 7b379a54..0f23e443 100644 --- a/src/_numtype/__init__.pyi +++ b/src/_numtype/__init__.pyi @@ -9,7 +9,7 @@ from typing import Any, TypeAlias, type_check_only from typing_extensions import Protocol, TypeAliasType, TypeVar import numpy as np -from numpy._typing import _NestedSequence +from numpy._typing import _NestedSequence # noqa: PLC2701 from . import op as op from ._array import ( diff --git a/src/_numtype/_dtype.pyi b/src/_numtype/_dtype.pyi index 489c6230..43dd52c3 100644 --- a/src/_numtype/_dtype.pyi +++ b/src/_numtype/_dtype.pyi @@ -1,3 +1,5 @@ +# ruff: noqa: PLC2701 + import ctypes as ct from typing import Any, TypeAlias, type_check_only from typing_extensions import Protocol, TypeAliasType, TypeVar diff --git a/src/_numtype/_nep50.pyi b/src/_numtype/_nep50.pyi index 1294791b..dcf8bdb1 100644 --- a/src/_numtype/_nep50.pyi +++ b/src/_numtype/_nep50.pyi @@ -6,7 +6,7 @@ from typing import Any, Protocol, TypeAlias, type_check_only from typing_extensions import TypeAliasType, TypeVar import numpy as np -from numpy._typing import _NestedSequence +from numpy._typing import _NestedSequence # noqa: PLC2701 from . import _shape from ._rank import Rank0 diff --git a/src/numpy-stubs/.ruff.toml b/src/numpy-stubs/.ruff.toml index ffbbc2b6..5a74e5e2 100644 --- a/src/numpy-stubs/.ruff.toml +++ b/src/numpy-stubs/.ruff.toml @@ -4,7 +4,9 @@ line-length = 120 [lint] extend-ignore = [ "A", # flake8-builtins + "N", # pep8-naming "ANN401", # flake8-annotations: any-type "SLF001", # flake8-self: private-member-access - "PLR2044", # pylint/R: empty-comment + "PLC2701", # pylint/convention: import-private-name + "PLR2044", # pylint/refactor: empty-comment ] diff --git a/src/numpy-stubs/@test/.ruff.toml b/src/numpy-stubs/@test/.ruff.toml index 0285bcd7..71cd44ee 100644 --- a/src/numpy-stubs/@test/.ruff.toml +++ b/src/numpy-stubs/@test/.ruff.toml @@ -1,9 +1,9 @@ -extend = "../../../pyproject.toml" +extend = "../.ruff.toml" line-length = 88 [lint] extend-ignore = [ "D", # pydocstyle - "FBT", # flake8-boolean-trap + "FBT003", # flake8-boolean-trap: boolean-positional-value-in-call "PYI054", # flake8-pyi: numeric-literal-too-long ] diff --git a/src/numpy-stubs/@test/runtime/legacy/arithmetic.py b/src/numpy-stubs/@test/runtime/legacy/arithmetic.py index 2e7bcbbf..330168ff 100644 --- a/src/numpy-stubs/@test/runtime/legacy/arithmetic.py +++ b/src/numpy-stubs/@test/runtime/legacy/arithmetic.py @@ -28,7 +28,7 @@ class Object: def __array__( - self, dtype: npt.DTypeLike = None, copy: bool | None = None + self, dtype: npt.DTypeLike = None, *, copy: bool | None = None ) -> npt.NDArray[np.object_]: ret = np.empty((), dtype=np.object_) ret[()] = self diff --git a/src/numpy-stubs/@test/runtime/legacy/random.py b/src/numpy-stubs/@test/runtime/legacy/random.py index b0bd6e41..c0a6a374 100644 --- a/src/numpy-stubs/@test/runtime/legacy/random.py +++ b/src/numpy-stubs/@test/runtime/legacy/random.py @@ -1462,7 +1462,7 @@ random_st.randint(I_i8_low, I_i8_high_open, dtype=np.int64) random_st.randint(-9223372036854775808, I_i8_high_open, dtype=np.int64) -bg: np.random.BitGenerator = random_st._bit_generator # noqa: SLF001 +bg: np.random.BitGenerator = random_st._bit_generator random_st.bytes(2) diff --git a/src/numpy-stubs/@test/runtime/legacy/ufunclike.py b/src/numpy-stubs/@test/runtime/legacy/ufunclike.py index d89b0bc8..1f183536 100644 --- a/src/numpy-stubs/@test/runtime/legacy/ufunclike.py +++ b/src/numpy-stubs/@test/runtime/legacy/ufunclike.py @@ -17,7 +17,7 @@ def __ge__(self, value: object) -> bool: return True def __array__( - self, dtype: npt.DTypeLike | None = None, copy: bool | None = None + self, dtype: npt.DTypeLike | None = None, *, copy: bool | None = None ) -> np.ndarray[Any, np.dtype[np.object_]]: ret = np.empty((), dtype=object) ret[()] = self