Skip to content

Commit

Permalink
Merge pull request #19958 from charris/backport-19856
Browse files Browse the repository at this point in the history
MAINT: Mark type-check-only ufunc subclasses as ufunc aliases during runtime
  • Loading branch information
charris committed Sep 26, 2021
2 parents 13c259e + 6fb30f9 commit 51b7c50
Showing 1 changed file with 10 additions and 7 deletions.
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

0 comments on commit 51b7c50

Please sign in to comment.