@@ -1782,6 +1782,9 @@ else:
1782
1782
_T = TypeVar ("_T" )
1783
1783
_T_co = TypeVar ("_T_co" , covariant = True )
1784
1784
_T_contra = TypeVar ("_T_contra" , contravariant = True )
1785
+ _RealT_co = TypeVar ("_RealT_co" , covariant = True )
1786
+ _ImagT_co = TypeVar ("_ImagT_co" , covariant = True )
1787
+
1785
1788
_2Tuple : TypeAlias = tuple [_T , _T ]
1786
1789
_CastingKind : TypeAlias = L ["no" , "equiv" , "safe" , "same_kind" , "unsafe" ]
1787
1790
@@ -1823,35 +1826,39 @@ class _HasShapeAndDTypeWithItem(Protocol[_ShapeType_co, _T_co]):
1823
1826
def dtype (self , / ) -> _HashTypeWithItem [_T_co ]: ...
1824
1827
1825
1828
@type_check_only
1826
- class _SupportsReal (Protocol [_T_co ]):
1829
+ class _HasRealAndImag (Protocol [_RealT_co , _ImagT_co ]):
1830
+ @property
1831
+ def real (self , / ) -> _RealT_co : ...
1827
1832
@property
1828
- def real (self ) -> _T_co : ...
1833
+ def imag (self , / ) -> _ImagT_co : ...
1829
1834
1830
1835
@type_check_only
1831
- class _SupportsImag (Protocol [_T_co ]):
1836
+ class _HasTypeWithRealAndImag (Protocol [_RealT_co , _ImagT_co ]):
1832
1837
@property
1833
- def imag (self ) -> _T_co : ...
1838
+ def type (self , / ) -> type [_HasRealAndImag [_RealT_co , _ImagT_co ]]: ...
1839
+
1840
+ @type_check_only
1841
+ class _HasDTypeWithRealAndImag (Protocol [_RealT_co , _ImagT_co ]):
1842
+ @property
1843
+ def dtype (self , / ) -> _HasTypeWithRealAndImag [_RealT_co , _ImagT_co ]: ...
1834
1844
1835
1845
class ndarray (_ArrayOrScalarCommon , Generic [_ShapeType_co , _DType_co ]):
1836
- __hash__ : ClassVar [None ]
1846
+ __hash__ : ClassVar [None ] # type: ignore[assignment] # pyright: ignore[reportIncompatibleMethodOverride]
1837
1847
@property
1838
1848
def base (self ) -> None | NDArray [Any ]: ...
1839
1849
@property
1840
1850
def ndim (self ) -> int : ...
1841
1851
@property
1842
1852
def size (self ) -> int : ...
1843
1853
@property
1844
- def real (
1845
- self : ndarray [_ShapeType_co , dtype [_SupportsReal [_ScalarType ]]], # type: ignore[type-var]
1846
- ) -> ndarray [_ShapeType_co , _dtype [_ScalarType ]]: ...
1854
+ def real (self : _HasDTypeWithRealAndImag [_SCT , object ], / ) -> ndarray [_ShapeType_co , dtype [_SCT ]]: ...
1847
1855
@real .setter
1848
- def real (self , value : ArrayLike ) -> None : ...
1856
+ def real (self , value : ArrayLike , / ) -> None : ...
1849
1857
@property
1850
- def imag (
1851
- self : ndarray [_ShapeType_co , dtype [_SupportsImag [_ScalarType ]]], # type: ignore[type-var]
1852
- ) -> ndarray [_ShapeType_co , _dtype [_ScalarType ]]: ...
1858
+ def imag (self : _HasDTypeWithRealAndImag [object , _SCT ], / ) -> ndarray [_ShapeType_co , dtype [_SCT ]]: ...
1853
1859
@imag .setter
1854
- def imag (self , value : ArrayLike ) -> None : ...
1860
+ def imag (self , value : ArrayLike , / ) -> None : ...
1861
+
1855
1862
def __new__ (
1856
1863
cls ,
1857
1864
shape : _ShapeLike ,
0 commit comments