Skip to content
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

TYP: Relax the return-type of np.vectorize #20908

Merged
merged 2 commits into from Jan 28, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion numpy/__init__.pyi
Expand Up @@ -3679,6 +3679,8 @@ class memmap(ndarray[_ShapeType, _DType_co]):
) -> Any: ...
def flush(self) -> None: ...

# TODO: Add a mypy plugin for managing functions whose output type is dependant
# on the literal value of some sort of signature (e.g. `einsum` and `vectorize`)
class vectorize:
pyfunc: Callable[..., Any]
cache: bool
Expand All @@ -3695,7 +3697,7 @@ class vectorize:
cache: bool = ...,
signature: None | str = ...,
) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> NDArray[Any]: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...

class poly1d:
@property
Expand Down
2 changes: 1 addition & 1 deletion numpy/typing/tests/data/reveal/lib_function_base.pyi
Expand Up @@ -26,7 +26,7 @@ reveal_type(vectorized_func.signature) # E: Union[None, builtins.str]
reveal_type(vectorized_func.otypes) # E: Union[None, builtins.str]
reveal_type(vectorized_func.excluded) # E: set[Union[builtins.int, builtins.str]]
reveal_type(vectorized_func.__doc__) # E: Union[None, builtins.str]
reveal_type(vectorized_func([1])) # E: ndarray[Any, dtype[Any]]
reveal_type(vectorized_func([1])) # E: Any
reveal_type(np.vectorize(int)) # E: vectorize
reveal_type(np.vectorize( # E: vectorize
int, otypes="i", doc="doc", excluded=(), cache=True, signature=None
Expand Down