2929 "&" : op .__and__ ,
3030 "^" : op .__xor__ ,
3131 "|" : op .__or__ ,
32+ "<" : op .__lt__ ,
33+ "<=" : op .__le__ ,
34+ ">=" : op .__ge__ ,
35+ ">" : op .__gt__ ,
36+ # TODO(jorenham): these currently all return `Any`; fix this
37+ # "==": op.__eq__,
3238}
3339NAMES = {
3440 # builtins (key length > 1)
7076BITWISE_CHARS = "?bhilqBHILQ"
7177
7278
73- def _scalar (key : str , / ) -> np .generic | complex :
79+ def _scalar (key : str , / ) -> np .number | np . bool | np . timedelta64 | np . datetime64 | bool :
7480 if len (key ) > 1 :
7581 # must be one of the builtin scalars
76- pytype : type [complex ] = getattr (__builtins__ , key )
82+ pytype : type [bool ] = getattr (__builtins__ , key )
7783 return pytype (1 )
7884
7985 dtype = np .dtype (key )
@@ -105,7 +111,7 @@ def _assert_stmt(op: str, lhs: str, rhs: str, /) -> str | None:
105111 expr_eval = f"{ NAMES [lhs ]} { pad } { op } { pad } { NAMES [rhs ]} "
106112
107113 try :
108- val_out : np . generic = OPS [op ](_scalar (lhs ), _scalar (rhs ))
114+ val_out = OPS [op ](_scalar (lhs ), _scalar (rhs ))
109115 except TypeError :
110116 # generate rejection test, while avoiding trivial cases
111117 if op not in DATETIME_OPS and (lhs == "M" or rhs == "M" ):
@@ -125,9 +131,9 @@ def _assert_stmt(op: str, lhs: str, rhs: str, /) -> str | None:
125131 "# type: ignore[operator]" ,
126132 "# pyright: ignore[reportOperatorIssue]" ,
127133 ))
128- else :
129- expr_type = _sctype_expr (val_out .dtype )
130- return f"assert_type({ expr_eval } , { expr_type } )"
134+
135+ expr_type = _sctype_expr (val_out .dtype )
136+ return f"assert_type({ expr_eval } , { expr_type } )"
131137
132138
133139def _gen_imports () -> Generator [str ]:
0 commit comments