@@ -13,6 +13,7 @@ __all__ = [
13
13
"CastsScalar" ,
14
14
"CastsWith" ,
15
15
"CastsWithArray" ,
16
+ "CastsWithBuiltin" ,
16
17
"CastsWithComplex" ,
17
18
"CastsWithFloat" ,
18
19
"CastsWithInt" ,
@@ -23,6 +24,9 @@ __all__ = [
23
24
24
25
_LikeT_co = TypeVar ("_LikeT_co" , covariant = True )
25
26
27
+ _BuitinT = TypeVar ("_BuitinT" )
28
+ _BuitinT_co = TypeVar ("_BuitinT_co" , covariant = True )
29
+
26
30
_ScalarIn : TypeAlias = np .generic | str
27
31
_ScalarInT = TypeVar ("_ScalarInT" , bound = _ScalarIn )
28
32
_ScalarInT_contra = TypeVar ("_ScalarInT_contra" , bound = _ScalarIn , contravariant = True )
@@ -71,6 +75,10 @@ class _CanNEP50Rule6(Protocol[_ScalarInT_contra, _ScalarOutT_co]):
71
75
def __nep50_rule6__ (self , other : _ScalarInT_contra , / ) -> _ScalarOutT_co : ...
72
76
73
77
#
78
+ @type_check_only
79
+ class _CanNEP50Builtin (Protocol [_BuitinT_co , _ScalarOutT_co ]):
80
+ def __nep50_builtin__ (self , / ) -> tuple [_BuitinT_co , _ScalarOutT_co ]: ...
81
+
74
82
@type_check_only
75
83
class _CanNEP50Bool (Protocol [_ScalarOutT_co ]):
76
84
def __nep50_bool__ (self , / ) -> _ScalarOutT_co : ...
@@ -161,7 +169,8 @@ CastsWithScalar = TypeAliasType(
161
169
)
162
170
163
171
#
164
- CastsWithBool : TypeAlias = _CanNEP50Bool [_ScalarOutT ]
165
- CastsWithInt : TypeAlias = _CanNEP50Int [_ScalarOutT ]
166
- CastsWithFloat : TypeAlias = _CanNEP50Float [_ScalarOutT ]
167
- CastsWithComplex : TypeAlias = _CanNEP50Complex [_ScalarOutT ]
172
+ CastsWithBuiltin : TypeAlias = _LikeNumeric [_CanNEP50Builtin [_BuitinT , _ScalarOutT ], _ShapeT ]
173
+ CastsWithBool : TypeAlias = _LikeNumeric [_CanNEP50Bool [_ScalarOutT ], _ShapeT ]
174
+ CastsWithInt : TypeAlias = _LikeNumeric [_CanNEP50Int [_ScalarOutT ], _ShapeT ]
175
+ CastsWithFloat : TypeAlias = _LikeNumeric [_CanNEP50Float [_ScalarOutT ], _ShapeT ]
176
+ CastsWithComplex : TypeAlias = _LikeNumeric [_CanNEP50Complex [_ScalarOutT ], _ShapeT ]
0 commit comments