diff options
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/typing/__init__.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/numpy/typing/__init__.py b/numpy/typing/__init__.py index a9bf94f13..e72e8fb4d 100644 --- a/numpy/typing/__init__.py +++ b/numpy/typing/__init__.py @@ -120,7 +120,7 @@ API # NOTE: The API section will be appended with additional entries # further down in this file -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, List if TYPE_CHECKING: import sys @@ -131,6 +131,17 @@ if TYPE_CHECKING: else: def final(f): return f +if not TYPE_CHECKING: + __all__ = ["ArrayLike", "DTypeLike", "NBitBase"] +else: + # Ensure that all objects within this module are accessible while + # static type checking. This includes private ones, as we need them + # for internal use. + # + # Declare to mypy that `__all__` is a list of strings without assigning + # an explicit value + __all__: List[str] + @final # Dissallow the creation of arbitrary `NBitBase` subclasses class NBitBase: @@ -194,7 +205,7 @@ class _16Bit(_32Bit): ... # type: ignore[misc] class _8Bit(_16Bit): ... # type: ignore[misc] # Clean up the namespace -del TYPE_CHECKING, final +del TYPE_CHECKING, final, List from ._scalars import ( _CharLike, @@ -213,7 +224,7 @@ from ._dtype_like import _SupportsDType, _VoidDTypeLike, DTypeLike if __doc__ is not None: from ._add_docstring import _docstrings __doc__ += _docstrings - __doc__ += f'\n.. autoclass:: numpy.typing.NBitBase\n' + __doc__ += '\n.. autoclass:: numpy.typing.NBitBase\n' del _docstrings from numpy._pytesttester import PytestTester |
