diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2021-09-09 09:08:00 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-09 09:08:00 -0600 |
commit | 8ba424fddf84f49ee9b8c2a60e315d1d4599edc0 (patch) | |
tree | 2758e964154d28756bd859fb936d64604cdd67cd | |
parent | 548bc6826b597ab79b9c1451b79ec8d23db9d444 (diff) | |
parent | 739e89d8320442d5fe416867a839963854286d0f (diff) | |
download | numpy-8ba424fddf84f49ee9b8c2a60e315d1d4599edc0.tar.gz |
Merge pull request #19856 from BvB93/ufunc-subclass
MAINT: Mark type-check-only ufunc subclasses as ufunc aliases during runtime
-rw-r--r-- | numpy/typing/__init__.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/numpy/typing/__init__.py b/numpy/typing/__init__.py index d60ddb5bb..c7cbf0f72 100644 --- a/numpy/typing/__init__.py +++ b/numpy/typing/__init__.py @@ -136,7 +136,8 @@ API # NOTE: The API section will be appended with additional entries # further down in this file -from typing import TYPE_CHECKING, List, Any, final +from numpy import ufunc +from typing import TYPE_CHECKING, List, final if not TYPE_CHECKING: __all__ = ["ArrayLike", "DTypeLike", "NBitBase", "NDArray"] @@ -334,14 +335,16 @@ if TYPE_CHECKING: _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 |