11from _typeshed import SupportsWrite
22from collections .abc import Callable
3- from typing import Any , Literal , TypeAlias , TypedDict , type_check_only
3+ from types import TracebackType
4+ from typing import Any , Final , Literal , TypeAlias , TypedDict , TypeVar , type_check_only
45
5- from numpy import errstate as errstate
6+ __all__ = [
7+ "seterr" ,
8+ "geterr" ,
9+ "setbufsize" ,
10+ "getbufsize" ,
11+ "seterrcall" ,
12+ "geterrcall" ,
13+ "errstate" ,
14+ ]
615
716_ErrKind : TypeAlias = Literal ["ignore" , "warn" , "raise" , "call" , "print" , "log" ]
8- _ErrFunc : TypeAlias = Callable [[str , int ], Any ]
9- _ErrCall : TypeAlias = _ErrFunc | SupportsWrite [str ]
17+ _ErrCall : TypeAlias = Callable [[str , int ], Any ] | SupportsWrite [str ]
18+
19+ _CallableT = TypeVar ("_CallableT" , bound = Callable [..., object ])
1020
1121@type_check_only
1222class _ErrDict (TypedDict ):
@@ -15,6 +25,36 @@ class _ErrDict(TypedDict):
1525 under : _ErrKind
1626 invalid : _ErrKind
1727
28+ ###
29+
30+ class _unspecified : ...
31+
32+ _Unspecified : Final [_unspecified ]
33+
34+ class errstate :
35+ __slots__ = "_all" , "_call" , "_divide" , "_invalid" , "_over" , "_token" , "_under"
36+
37+ def __init__ (
38+ self ,
39+ / ,
40+ * ,
41+ call : _ErrCall | _unspecified = ..., # = _Unspecified
42+ all : _ErrKind | None = None ,
43+ divide : _ErrKind | None = None ,
44+ over : _ErrKind | None = None ,
45+ under : _ErrKind | None = None ,
46+ invalid : _ErrKind | None = None ,
47+ ) -> None : ...
48+ def __call__ (self , / , func : _CallableT ) -> _CallableT : ...
49+ def __enter__ (self ) -> None : ...
50+ def __exit__ (
51+ self ,
52+ exc_type : type [BaseException ] | None ,
53+ exc_value : BaseException | None ,
54+ traceback : TracebackType | None ,
55+ / ,
56+ ) -> None : ...
57+
1858def seterr (
1959 all : _ErrKind | None = None ,
2060 divide : _ErrKind | None = None ,
@@ -27,5 +67,3 @@ def setbufsize(size: int) -> int: ...
2767def getbufsize () -> int : ...
2868def seterrcall (func : _ErrCall | None ) -> _ErrCall | None : ...
2969def geterrcall () -> _ErrCall | None : ...
30-
31- # See `numpy/__init__.pyi` for the `errstate` class and `no_nep5_warnings`
0 commit comments