8000 CI,TYP: Bump mypy to 1.4.1 by BvB93 · Pull Request #23764 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

CI,TYP: Bump mypy to 1.4.1 #23764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 25, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
TYP: Improve function-based annotations with typing.Concatenate
  • Loading branch information
BvB93 committed Aug 23, 2023
commit 4a74d38c15166385e2e4daef06dd310269ec6434
21 changes: 13 additions & 8 deletions numpy/lib/shape_base.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import sys
from collections.abc import Callable, Sequence
from typing import TypeVar, Any, overload, SupportsIndex, Protocol

if sys.version_info >= (3, 10):
from typing import ParamSpec, Concatenate
else:
from typing_extensions import ParamSpec, Concatenate

from numpy import (
generic,
integer,
Expand Down Expand Up @@ -28,6 +34,7 @@ from numpy._typing import (

from numpy.core.shape_base import vstack

_P = ParamSpec("_P")
_SCT = TypeVar("_SCT", bound=generic)

# The signatures of `__array_wrap__` and `__array_prepare__` are the same;
Expand Down Expand Up @@ -73,23 +80,21 @@ def put_along_axis(
axis: None | int,
) -> None: ...

# TODO: Use PEP 612 `ParamSpec` once mypy supports `Concatenate`
# xref python/mypy#8645
@overload
def apply_along_axis(
func1d: Callable[..., _ArrayLike[_SCT]],
func1d: Callable[Concatenate[NDArray[Any], _P], _ArrayLike[_SCT]],
axis: SupportsIndex,
arr: ArrayLike,
*args: Any,
**kwargs: Any,
*args: _P.args,
**kwargs: _P.kwargs,
) -> NDArray[_SCT]: ...
@overload
def apply_along_axis(
func1d: Callable[..., ArrayLike],
func1d: Callable[Concatenate[NDArray[Any], _P], ArrayLike],
axis: SupportsIndex,
arr: ArrayLike,
*args: Any,
**kwargs: Any,
*args: _P.args,
**kwargs: _P.kwargs,
) -> NDArray[Any]: ...

def apply_over_axes(
Expand Down
0