22"""
33
44import ast
5- import operator
6- import sys
7- import inspect
85import tokenize
9- import datetime
106
117from functools import partial
128
2117from pandas .computation .ops import _reductions , _mathops , _LOCAL_TAG
2218from pandas .computation .ops import Op , BinOp , UnaryOp , Term , Constant , Div
2319from pandas .computation .ops import UndefinedVariableError , FuncNode
24- from pandas .computation .scope import Scope , _ensure_scope
20+ from pandas .computation .scope import Scope
2521
2622
2723def tokenize_string (source ):
@@ -381,9 +377,9 @@ def _possibly_evaluate_binop(self, op, op_class, lhs, rhs,
381377 rhs .type ))
382378
383379 if self .engine != 'pytables' :
384- if (res .op in _cmp_ops_syms
385- and getattr (lhs , 'is_datetime' , False )
386- or getattr (rhs , 'is_datetime' , False )):
380+ if (res .op in _cmp_ops_syms and
381+ getattr (lhs , 'is_datetime' , False ) or
382+ getattr (rhs , 'is_datetime' , False )):
387383 # all date ops must be done in python bc numexpr doesn't work
388384 # well with NaT
389385 return self ._possibly_eval (res , self .binary_ops )
@@ -392,8 +388,8 @@ def _possibly_evaluate_binop(self, op, op_class, lhs, rhs,
392388 # "in"/"not in" ops are always evaluated in python
393389 return self ._possibly_eval (res , eval_in_python )
394390 elif self .engine != 'pytables' :
395- if (getattr (lhs , 'return_type' , None ) == object
396- or getattr (rhs , 'return_type' , None ) == object ):
391+ if (getattr (lhs , 'return_type' , None ) == object or
392+ getattr (rhs , 'return_type' , None ) == object ):
397393 # evaluate "==" and "!=" in python if either of our operands
398394 # has an object return type
399395 return self ._possibly_eval (res , eval_in_python +
@@ -517,7 +513,8 @@ def visit_Attribute(self, node, **kwargs):
517513 raise ValueError ("Invalid Attribute context {0}" .format (ctx .__name__ ))
518514
519515 def visit_Call_35 (self , node , side = None , ** kwargs ):
520- """ in 3.5 the starargs attribute was changed to be more flexible, #11097 """
516+ """ in 3.5 the starargs attribute was changed to be more flexible,
517+ #11097 """
521518
522519 if isinstance (node .func , ast .Attribute ):
523520 res = self .visit_Attribute (node .func )
@@ -541,7 +538,7 @@ def visit_Call_35(self, node, side=None, **kwargs):
541538
542539 if isinstance (res , FuncNode ):
543540
544- new_args = [ self .visit (arg ) for arg in node .args ]
541+ new_args = [self .visit (arg ) for arg in node .args ]
545542
546543 if node .keywords :
547544 raise TypeError ("Function \" {0}\" does not support keyword "
@@ -551,15 +548,17 @@ def visit_Call_35(self, node, side=None, **kwargs):
551548
552549 else :
553550
554- new_args = [ self .visit (arg ).value for arg in node .args ]
551+ new_args = [self .visit (arg ).value for arg in node .args ]
555552
556553 for key in node .keywords :
557554 if not isinstance (key , ast .keyword ):
558555 raise ValueError ("keyword error in function call "
559556 "'{0}'" .format (node .func .id ))
560557
561558 if key .arg :
562- kwargs .append (ast .keyword (keyword .arg , self .visit (keyword .value )))
559+ # TODO: bug?
560+ kwargs .append (ast .keyword (
561+ keyword .arg , self .visit (keyword .value ))) # noqa
563562
564563 return self .const_type (res (* new_args , ** kwargs ), self .env )
565564
0 commit comments