11from collections .abc import Callable
2- from typing import Any , Literal , TypeAlias , TypedDict , type_check_only
2+ from types import TracebackType
3+ from typing import Any , Final , Literal , TypeAlias , TypedDict , TypeVar , type_check_only
34
4- from _typeshed import SupportsWrite
5-
6- from numpy import errstate as errstate
5+ __all__ = [
6+ "seterr" ,
7+ "geterr" ,
8+ "setbufsize" ,
9+ "getbufsize" ,
10+ "seterrcall" ,
11+ "geterrcall" ,
12+ "errstate" ,
13+ ]
714
815_ErrKind : TypeAlias = Literal ["ignore" , "warn" , "raise" , "call" , "print" , "log" ]
9- _ErrFunc : TypeAlias = Callable [[str , int ], Any ]
10- _ErrCall : TypeAlias = _ErrFunc | SupportsWrite [str ]
16+ _ErrCall : TypeAlias = Callable [[str , int ], Any ] | SupportsWrite [str ]
17+
18+ _CallableT = TypeVar ("_CallableT" , bound = Callable [..., object ])
1119
1220@type_check_only
1321class _ErrDict (TypedDict ):
@@ -16,6 +24,36 @@ class _ErrDict(TypedDict):
1624 under : _ErrKind
1725 invalid : _ErrKind
1826
27+ ###
28+
29+ class _unspecified : ...
30+
31+ _Unspecified : Final [_unspecified ]
32+
33+ class errstate :
34+ __slots__ = "_all" , "_call" , "_divide" , "_invalid" , "_over" , "_token" , "_under"
35+
36+ def __init__ (
37+ self ,
38+ / ,
39+ * ,
40+ call : _ErrCall | _unspecified = ..., # = _Unspecified
41+ all : _ErrKind | None = None ,
42+ divide : _ErrKind | None = None ,
43+ over : _ErrKind | None = None ,
44+ under : _ErrKind | None = None ,
45+ invalid : _ErrKind | None = None ,
46+ ) -> None : ...
47+ def __call__ (self , / , func : _CallableT ) -> _CallableT : ...
48+ def __enter__ (self ) -> None : ...
49+ def __exit__ (
50+ self ,
51+ exc_type : type [BaseException ] | None ,
52+ exc_value : BaseException | None ,
53+ traceback : TracebackType | None ,
54+ / ,
55+ ) -> None : ...
56+
1957def seterr (
2058 all : _ErrKind | None = ...,
2159 divide : _ErrKind | None = ...,
@@ -28,5 +66,3 @@ def setbufsize(size: int) -> int: ...
2866def getbufsize () -> int : ...
2967def seterrcall (func : _ErrCall | None ) -> _ErrCall | None : ...
3068def geterrcall () -> _ErrCall | None : ...
31-
32- # See `numpy/__init__.pyi` for the `errstate` class and `no_nep5_warnings`
0 commit comments