@@ -70,6 +70,7 @@ def __new__(cls, name, env, side=None, encoding=None):
70
70
return supr_new (klass )
71
71
72
72
def __init__ (self , name , env , side = None , encoding = None ):
73
+ # name is a str for Term, but may be something else for subclasses
73
74
self ._name = name
74
75
self .env = env
75
76
self .side = side
@@ -79,7 +80,7 @@ def __init__(self, name, env, side=None, encoding=None):
79
80
self .encoding = encoding
80
81
81
82
@property
82
- def local_name (self ):
83
+ def local_name (self ) -> str :
83
84
return self .name .replace (_LOCAL_TAG , "" )
84
85
85
86
def __repr__ (self ) -> str :
@@ -120,7 +121,7 @@ def update(self, value):
120
121
self .value = value
121
122
122
123
@property
123
- def is_scalar (self ):
124
+ def is_scalar (self ) -> bool :
124
125
return is_scalar (self ._value )
125
126
126
127
@property
@@ -139,14 +140,14 @@ def type(self):
139
140
return_type = type
140
141
141
142
@property
142
- def raw (self ):
143
+ def raw (self ) -> str :
143
144
return pprint_thing (
144
145
"{0}(name={1!r}, type={2})"
145
146
"" .format (self .__class__ .__name__ , self .name , self .type )
146
147
)
147
148
148
149
@property
149
- def is_datetime (self ):
150
+ def is_datetime (self ) -> bool :
150
151
try :
151
152
t = self .type .type
152
153
except AttributeError :
@@ -220,7 +221,7 @@ def return_type(self):
220
221
return _result_type_many (* (term .type for term in com .flatten (self )))
221
222
222
223
@property
223
- def has_invalid_return_type (self ):
224
+ def has_invalid_return_type (self ) -> bool :
224
225
types = self .operand_types
225
226
obj_dtype_set = frozenset ([np .dtype ("object" )])
226
227
return self .return_type == object and types - obj_dtype_set
@@ -230,11 +231,11 @@ def operand_types(self):
230
231
return frozenset (term .type for term in com .flatten (self ))
231
232
232
233
@property
233
- def is_scalar (self ):
234
+ def is_scalar (self ) -> bool :
234
235
return all (operand .is_scalar for operand in self .operands )
235
236
236
237
@property
237
- def is_datetime (self ):
238
+ def is_datetime (self ) -> bool :
238
239
try :
239
240
t = self .return_type .type
240
241
except AttributeError :
@@ -339,7 +340,7 @@ def _cast_inplace(terms, acceptable_dtypes, dtype):
339
340
term .update (new_value )
340
341
341
342
342
- def is_term (obj ):
343
+ def is_term (obj ) -> bool :
343
344
return isinstance (obj , Term )
344
345
345
346
@@ -354,7 +355,7 @@ class BinOp(Op):
354
355
right : Term or Op
355
356
"""
356
357
357
- def __init__ (self , op , lhs , rhs , ** kwargs ):
358
+ def __init__ (self , op : str , lhs , rhs , ** kwargs ):
358
359
super ().__init__ (op , (lhs , rhs ))
359
360
self .lhs = lhs
360
361
self .rhs = rhs
@@ -396,7 +397,7 @@ def __call__(self, env):
396
397
397
398
return self .func (left , right )
398
399
399
- def evaluate (self , env , engine , parser , term_type , eval_in_python ):
400
+ def evaluate (self , env , engine : str , parser , term_type , eval_in_python ):
400
401
"""
401
402
Evaluate a binary operation *before* being passed to the engine.
402
403
@@ -488,7 +489,7 @@ def _disallow_scalar_only_bool_ops(self):
488
489
raise NotImplementedError ("cannot evaluate scalar only bool ops" )
489
490
490
491
491
- def isnumeric (dtype ):
492
+ def isnumeric (dtype ) -> bool :
492
493
return issubclass (np .dtype (dtype ).type , np .number )
493
494
494
495
@@ -505,8 +506,8 @@ class Div(BinOp):
505
506
regardless of the value of ``truediv``.
506
507
"""
507
508
508
- def __init__ (self , lhs , rhs , truediv , * args , ** kwargs ):
509
- super ().__init__ ("/" , lhs , rhs , * args , * *kwargs )
509
+ def __init__ (self , lhs , rhs , truediv : bool , ** kwargs ):
510
+ super ().__init__ ("/" , lhs , rhs , ** kwargs )
510
511
511
512
if not isnumeric (lhs .return_type ) or not isnumeric (rhs .return_type ):
512
513
raise TypeError (
@@ -541,7 +542,7 @@ class UnaryOp(Op):
541
542
* If no function associated with the passed operator token is found.
542
543
"""
543
544
544
- def __init__ (self , op , operand ):
545
+ def __init__ (self , op : str , operand ):
545
546
super ().__init__ (op , (operand ,))
546
547
self .operand = operand
547
548
@@ -561,7 +562,7 @@ def __repr__(self) -> str:
561
562
return pprint_thing ("{0}({1})" .format (self .op , self .operand ))
562
563
563
564
@property
564
- def return_type (self ):
565
+ def return_type (self ) -> np . dtype :
565
566
operand = self .operand
566
567
if operand .return_type == np .dtype ("bool" ):
567
568
return np .dtype ("bool" )
@@ -588,7 +589,7 @@ def __repr__(self) -> str:
588
589
589
590
590
591
class FuncNode :
591
- def __init__ (self , name ):
592
+ def __init__ (self , name : str ):
592
593
from pandas .core .computation .check import _NUMEXPR_INSTALLED , _NUMEXPR_VERSION
593
594
594
595
if name not in _mathops or (
0 commit comments