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

MAINT: Mark type-check-only ufunc subclasses as ufunc aliases during runtime #19958

Merged
merged 1 commit into from Sep 26, 2021
Merged
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
17 changes: 10 additions & 7 deletions numpy/typing/__init__.py
Expand Up @@ -161,7 +161,8 @@
# NOTE: The API section will be appended with additional entries
# further down in this file

from typing import TYPE_CHECKING, List, Any
from numpy import ufunc
from typing import TYPE_CHECKING, List

if TYPE_CHECKING:
import sys
Expand Down Expand Up @@ -364,14 +365,16 @@ class _8Bit(_16Bit): ... # type: ignore[misc]
_GUFunc_Nin2_Nout1,
)
else:
_UFunc_Nin1_Nout1 = Any
_UFunc_Nin2_Nout1 = Any
_UFunc_Nin1_Nout2 = Any
_UFunc_Nin2_Nout2 = Any
_GUFunc_Nin2_Nout1 = Any
# Declare the (type-check-only) ufunc subclasses as ufunc aliases during
# runtime; this helps autocompletion tools such as Jedi (numpy/numpy#19834)
_UFunc_Nin1_Nout1 = ufunc
_UFunc_Nin2_Nout1 = ufunc
_UFunc_Nin1_Nout2 = ufunc
_UFunc_Nin2_Nout2 = ufunc
_GUFunc_Nin2_Nout1 = ufunc

# Clean up the namespace
del TYPE_CHECKING, final, List, Any
del TYPE_CHECKING, final, List, ufunc

if __doc__ is not None:
from ._add_docstring import _docstrings
Expand Down