File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -365,25 +365,30 @@ def get_arithmetic_middle(root):
365365
366366
367367# Extract Left Middle Right from Boolean expressions
368+ def get_boolean (root ):
369+ if not match_node (root ,ast .BoolOp ) or match_parent (root ,ast .BoolOp ):
370+ return None
371+ return root
372+
368373
369374def get_boolean_left (root ):
370- if not match_node (root ,ast .BoolOp ):
375+ if not match_node (root ,ast .BoolOp ) or match_parent ( root , ast . BoolOp ) :
371376 return None
372377 items = root .values
373378 if len (items )>= 1 :
374379 return items [0 ]
375380 return None
376381
377382def get_boolean_right (root ):
378- if not match_node (root ,ast .BoolOp ):
383+ if not match_node (root ,ast .BoolOp ) or match_parent ( root , ast . BoolOp ) :
379384 return None
380385 items = root .values
381386 if len (items )>= 2 :
382387 return items [- 1 ]
383388 return None
384389
385390def get_boolean_middle (root ):
386- if not match_node (root ,ast .BoolOp ):
391+ if not match_node (root ,ast .BoolOp ) or match_parent ( root , ast . BoolOp ) :
387392 return None
388393 items = root .values
389394 if len (items )== 3 :
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ def standard(x):
120120 "attribute" :((ast .Attribute ),(),standard ),
121121 "comparison" :((ast .Compare ),(),standard ),
122122 "arithmetic" :((ast .BinOp ),(),get_arithmetic ),
123- "boolean" :((ast .BoolOp ),(),standard ),
123+ "boolean" :((ast .BoolOp ),(),get_boolean ),
124124
125125 "container" :((ast .Compare ),(),get_container_check ),
126126 "member" :((ast .Compare ),(),get_member_check ),
You can’t perform that action at this time.
0 commit comments