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
9 changes: 9 additions & 0 deletions docs/user/differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ from typing import TypeVar

NT = TypeVar("NT", bound=npt.NBitBase)


def f(x: np.floating[NT]) -> np.floating[NT]: ...
```

Expand All @@ -68,6 +69,7 @@ def f(x: np.floating[NT]) -> np.floating[NT]: ...
import numpy as np
import numpy.typing as npt


def f[NT: npt.NBitBase](x: np.floating[NT]) -> np.floating[NT]: ...
```

Expand All @@ -87,6 +89,7 @@ from typing import TypeVar

FloatT = TypeVar("FloatT", bound=np.floating)


def f(x: FloatT) -> FloatT: ...
```

Expand All @@ -101,6 +104,7 @@ def f(x: FloatT) -> FloatT: ...
```py
import numpy as np


def f[FloatT: np.floating](x: FloatT) -> FloatT: ...
```

Expand All @@ -123,6 +127,7 @@ from typing import TypeVar

NT = TypeVar("NT", bound=npt.NBitBase)


def f(x: np.complexfloating[NT]) -> np.floating[NT]: ...
```

Expand All @@ -136,6 +141,7 @@ def f(x: np.complexfloating[NT]) -> np.floating[NT]: ...
import numpy as np
import numpy.typing as npt


def f[NT: npt.NBitBase](x: np.complexfloating[NT]) -> np.floating[NT]: ...
```

Expand All @@ -150,6 +156,7 @@ In that case, you can rewrite it by using
import numpy as np
from typing import overload


@overload
def f(x: np.complex64) -> np.float32: ...
@overload
Expand Down Expand Up @@ -205,9 +212,11 @@ the following type-unsafe code:
```py
import numpy as np


def half(a: np.number) -> np.number:
return a // 2


half(np.complex128(1j)) # accepted
```

Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Changelog = "https://github.com/numpy/numtype/releases"
[dependency-groups]
numpy = ["numtype[numpy]"]
lint = [
"dprint-py>=0.51.1.0",
"ruff>=0.15.1",
"dprint-py>=0.52.0.0",
"ruff>=0.15.5",
]
pytest = [
{ include-group = "numpy" },
Expand All @@ -60,7 +60,7 @@ list_and_test = [
types = [
{ include-group = "pytest" },
"types-setuptools>=82.0.0.20260210",
"types-tabulate>=0.9.0.20241207",
"types-tabulate>=0.10.0.20260308",
]
basedpyright = [
{ include-group = "numpy" },
Expand All @@ -76,7 +76,7 @@ typecheck = [
{ include-group = "mypy" },
]
docs = [
"mkdocs-material>=9.7.1",
"mkdocs-material>=9.7.4",
"mkdocs-awesome-nav>=3.3.0",
"markdown-callouts>=0.4.0",
"mkdocs-include-markdown-plugin>=7.2.1",
Expand Down
1 change: 0 additions & 1 deletion src/numpy-stubs/_core/_multiarray_umath.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# ruff: noqa: F811
import _contextvars
import datetime as dt
from _typeshed import Incomplete, StrOrBytesPath, SupportsLenAndGetItem
Expand Down
Loading