@@ -15,19 +15,20 @@ import semmle.python.pointsto.PointsTo
1515
1616predicate rhs_in_expr ( ControlFlowNode rhs , Compare cmp ) {
1717 exists ( Cmpop op , int i | cmp .getOp ( i ) = op and cmp .getComparator ( i ) = rhs .getNode ( ) |
18- op instanceof In or op instanceof NotIn
18+ op instanceof In or op instanceof NotIn
1919 )
2020}
2121
2222from ControlFlowNode non_seq , Compare cmp , Value v , ClassValue cls , ControlFlowNode origin
23- where rhs_in_expr ( non_seq , cmp ) and
24- non_seq .pointsTo ( _, v , origin ) and
25- v .getClass ( ) = cls and
26- not Types:: failedInference ( cls , _) and
27- not cls .hasAttribute ( "__contains__" ) and
28- not cls .hasAttribute ( "__iter__" ) and
29- not cls .hasAttribute ( "__getitem__" ) and
30- not cls = ClassValue:: nonetype ( ) and
31- not cls = Value:: named ( "types.MappingProxyType" )
32-
33- select cmp , "This test may raise an Exception as the $@ may be of non-container class $@." , origin , "target" , cls , cls .getName ( )
23+ where
24+ rhs_in_expr ( non_seq , cmp ) and
25+ non_seq .pointsTo ( _, v , origin ) and
26+ v .getClass ( ) = cls and
27+ not Types:: failedInference ( cls , _) and
28+ not cls .hasAttribute ( "__contains__" ) and
29+ not cls .hasAttribute ( "__iter__" ) and
30+ not cls .hasAttribute ( "__getitem__" ) and
31+ not cls = ClassValue:: nonetype ( ) and
32+ not cls = Value:: named ( "types.MappingProxyType" )
33+ select cmp , "This test may raise an Exception as the $@ may be of non-container class $@." , origin ,
34+ "target" , cls , cls .getName ( )
0 commit comments