@@ -2612,8 +2612,6 @@ _NBit1 = TypeVar("_NBit1", bound=NBitBase)
26122612_NBit2 = TypeVar ("_NBit2" , bound = NBitBase )
26132613
26142614class generic (_ArrayOrScalarCommon ):
2615- @abstractmethod
2616- def __init__ (self , * args : Any , ** kwargs : Any ) -> None : ...
26172615 @overload
26182616 def __array__ (self : _ScalarType , dtype : None = ..., / ) -> NDArray [_ScalarType ]: ...
26192617 @overload
@@ -2839,12 +2837,41 @@ class bool(generic):
28392837
28402838bool_ = bool
28412839
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).
28422853class 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+
28442871 @property
2845- def real (self : _ArraySelf ) -> _ArraySelf : ...
2872+ def real (self ) -> object_ : ...
28462873 @property
2847- def imag (self : _ArraySelf ) -> _ArraySelf : ...
2874+ def imag (self ) -> object_ : ...
28482875 # The 3 protocols below may or may not raise,
28492876 # depending on the underlying object
28502877 def __int__ (self ) -> int : ...
0 commit comments