summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/__init__.pyi24
-rw-r--r--numpy/exceptions.pyi24
-rw-r--r--numpy/typing/tests/data/reveal/modules.pyi1
3 files changed, 28 insertions, 21 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index 8627f6c60..c7807e3ed 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -209,6 +209,7 @@ from numpy import (
random as random,
testing as testing,
version as version,
+ exceptions as exceptions,
)
from numpy.core import defchararray, records
@@ -411,6 +412,15 @@ from numpy.core.shape_base import (
vstack as vstack,
)
+from numpy.exceptions import (
+ ComplexWarning as ComplexWarning,
+ ModuleDeprecationWarning as ModuleDeprecationWarning,
+ VisibleDeprecationWarning as VisibleDeprecationWarning,
+ TooHardError as TooHardError,
+ DTypePromotionError as DTypePromotionError,
+ AxisError as AxisError,
+)
+
from numpy.lib import (
emath as emath,
)
@@ -3319,22 +3329,8 @@ class _CopyMode(enum.Enum):
NEVER: L[2]
# Warnings
-class ModuleDeprecationWarning(DeprecationWarning): ...
-class VisibleDeprecationWarning(UserWarning): ...
-class ComplexWarning(RuntimeWarning): ...
class RankWarning(UserWarning): ...
-# Errors
-class TooHardError(RuntimeError): ...
-
-class AxisError(ValueError, IndexError):
- axis: None | int
- ndim: None | int
- @overload
- def __init__(self, axis: str, ndim: None = ..., msg_prefix: None = ...) -> None: ...
- @overload
- def __init__(self, axis: int, ndim: int, msg_prefix: None | str = ...) -> None: ...
-
_CallType = TypeVar("_CallType", bound=_ErrFunc | _SupportsWrite[str])
class errstate(Generic[_CallType], ContextDecorator):
diff --git a/numpy/exceptions.pyi b/numpy/exceptions.pyi
index 53b7a0c16..c76a0946b 100644
--- a/numpy/exceptions.pyi
+++ b/numpy/exceptions.pyi
@@ -1,8 +1,18 @@
-from numpy.exceptions import (
- ComplexWarning as ComplexWarning,
- ModuleDeprecationWarning as ModuleDeprecationWarning,
- VisibleDeprecationWarning as VisibleDeprecationWarning,
- TooHardError as TooHardError,
- AxisError as AxisError,
-)
+from typing import overload
+__all__: list[str]
+
+class ComplexWarning(RuntimeWarning): ...
+class ModuleDeprecationWarning(DeprecationWarning): ...
+class VisibleDeprecationWarning(UserWarning): ...
+class TooHardError(RuntimeError): ...
+class DTypePromotionError(TypeError): ...
+
+class AxisError(ValueError, IndexError):
+ axis: None | int
+ ndim: None | int
+ @overload
+ def __init__(self, axis: str, ndim: None = ..., msg_prefix: None = ...) -> None: ...
+ @overload
+ def __init__(self, axis: int, ndim: int, msg_prefix: None | str = ...) -> None: ...
+ def __str__(self) -> str: ...
diff --git a/numpy/typing/tests/data/reveal/modules.pyi b/numpy/typing/tests/data/reveal/modules.pyi
index ba830eb0d..7d6fdb9eb 100644
--- a/numpy/typing/tests/data/reveal/modules.pyi
+++ b/numpy/typing/tests/data/reveal/modules.pyi
@@ -16,6 +16,7 @@ reveal_type(np.random) # E: ModuleType
reveal_type(np.rec) # E: ModuleType
reveal_type(np.testing) # E: ModuleType
reveal_type(np.version) # E: ModuleType
+reveal_type(np.exceptions) # E: ModuleType
reveal_type(np.lib.format) # E: ModuleType
reveal_type(np.lib.mixins) # E: ModuleType