@@ -2612,8 +2612,6 @@ _NBit1 = TypeVar("_NBit1", bound=NBitBase)
2612
2612
_NBit2 = TypeVar ("_NBit2" , bound = NBitBase )
2613
2613
2614
2614
class generic (_ArrayOrScalarCommon ):
2615
- @abstractmethod
2616
- def __init__ (self , * args : Any , ** kwargs : Any ) -> None : ...
2617
2615
@overload
2618
2616
def __array__ (self : _ScalarType , dtype : None = ..., / ) -> NDArray [_ScalarType ]: ...
2619
2617
@overload
@@ -2839,12 +2837,41 @@ class bool(generic):
2839
2837
2840
2838
bool_ = bool
2841
2839
2840
+ _StringType = TypeVar ("_StringType" , bound = str | bytes )
2841
+ _StringType = TypeVar ("_StringType" , bound = str | bytes )
2842
+ _ShapeType = TypeVar ("_ShapeType" , bound = Any )
2843
+ _ObjectType = TypeVar ("_ObjectType" , bound = object )
2844
+
2845
+ # A sequence-like interface like `collections.abc.Sequence`, but without the
2846
+ # irrelevant methods.
2847
+ class _SimpleSequence (Protocol ):
2848
+ def __len__ (self , / ) -> int : ...
2849
+ def __getitem__ (self , index : int , / ) -> Any : ...
2850
+
2851
+ # The `object_` constructor returns the passed object, so instances with type
2852
+ # `object_` cannot exists (at runtime).
2842
2853
class object_ (generic ):
2843
- def __init__ (self , value : object = ..., / ) -> None : ...
2854
+ @overload
2855
+ def __new__ (cls , nothing_to_see_here : None = ..., / ) -> None : ...
2856
+ @overload
2857
+ def __new__ (cls , stringy : _StringType , / ) -> _StringType : ...
2858
+ @overload
2859
+ def __new__ (
2860
+ cls ,
2861
+ array : ndarray [_ShapeType , Any ], / ,
2862
+ ) -> ndarray [_ShapeType , dtype [object_ ]]: ...
2863
+ @overload
2864
+ def __new__ (cls , sequence : _SimpleSequence , / ) -> NDArray [object_ ]: ...
2865
+ @overload
2866
+ def __new__ (cls , value : _ObjectType , / ) -> _ObjectType : ...
2867
+ # catch-all
2868
+ @overload
2869
+ def __new__ (cls , value : Any = ..., / ) -> object | NDArray [object_ ]: ...
2870
+
2844
2871
@property
2845
- def real (self : _ArraySelf ) -> _ArraySelf : ...
2872
+ def real (self ) -> object_ : ...
2846
2873
@property
2847
- def imag (self : _ArraySelf ) -> _ArraySelf : ...
2874
+ def imag (self ) -> object_ : ...
2848
2875
# The 3 protocols below may or may not raise,
2849
2876
# depending on the underlying object
2850
2877
def __int__ (self ) -> int : ...
0 commit comments