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
21 changes: 16 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ dev = [
{ include-group = "docs" },
]

# hatch

[tool.hatch.build]
exclude = [
"**/@test",
Expand All @@ -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
Expand All @@ -115,6 +119,8 @@ local_partial_types = true
warn_incomplete_stub = true
warn_unreachable = false

# (based)pyright

[tool.pyright]
include = ["src", "tool"]
ignore = [".venv"]
Expand Down Expand Up @@ -165,6 +171,8 @@ reportPrivateLocalImportUsage = true
reportUnannotatedClassAttribute = false
strictGenericNarrowing = true

# ruff

[tool.ruff]
src = ["src", "tool"]
extend-exclude = [".git", ".mypy_cache", ".tox", ".venv"]
Expand All @@ -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]
Expand Down Expand Up @@ -224,16 +230,19 @@ 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"]
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 = [
Expand Down Expand Up @@ -295,6 +304,8 @@ commands = [
],
]

# typos

[tool.typos]

[tool.typos.default]
Expand Down
12 changes: 6 additions & 6 deletions src/_numtype/@test/test_can_array_0d.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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"")
2 changes: 1 addition & 1 deletion src/_numtype/@test/test_rank_shape.pyi
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/_numtype/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 2 additions & 0 deletions src/_numtype/_dtype.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/_numtype/_nep50.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/numpy-stubs/.ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
4 changes: 2 additions & 2 deletions src/numpy-stubs/@test/.ruff.toml
Original file line number Diff line number Diff line change
@@ -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
]
2 changes: 1 addition & 1 deletion src/numpy-stubs/@test/runtime/legacy/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/numpy-stubs/@test/runtime/legacy/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/numpy-stubs/@test/runtime/legacy/ufunclike.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading