@@ -22,10 +22,10 @@ predicate declaredInAll(Module m, StrConst name)
2222 )
2323}
2424
25- predicate mutates_globals ( PythonModuleObject m ) {
25+ predicate mutates_globals ( ModuleValue m ) {
2626 exists ( CallNode globals |
2727 globals = Object:: builtin ( "globals" ) .( FunctionObject ) .getACall ( ) and
28- globals .getScope ( ) = m .getModule ( ) |
28+ globals .getScope ( ) = m .getScope ( ) |
2929 exists ( AttrNode attr | attr .getObject ( ) = globals )
3030 or
3131 exists ( SubscriptNode sub | sub .getValue ( ) = globals and sub .isStore ( ) )
@@ -34,19 +34,19 @@ predicate mutates_globals(PythonModuleObject m) {
3434 exists ( Object enum_convert |
3535 enum_convert .hasLongName ( "enum.Enum._convert" ) and
3636 exists ( CallNode call |
37- call .getScope ( ) = m .getModule ( )
37+ call .getScope ( ) = m .getScope ( )
3838 |
3939 enum_convert .( FunctionObject ) .getACall ( ) = call or
4040 call .getFunction ( ) .refersTo ( enum_convert )
4141 )
4242 )
4343}
4444
45- from PythonModuleObject m , StrConst name , string exported_name
46- where declaredInAll ( m .getModule ( ) , name ) and
45+ from ModuleValue m , StrConst name , string exported_name
46+ where declaredInAll ( m .getScope ( ) , name ) and
4747exported_name = name .strValue ( ) and
4848not m .hasAttribute ( exported_name ) and
49- not ( m .getShortName ( ) = "__init__" and exists ( m .getPackage ( ) .getModule ( ) .getSubModule ( exported_name ) ) ) and
50- not exists ( ImportStarNode imp | imp .getEnclosingModule ( ) = m .getModule ( ) | not imp .getModule ( ) .refersTo ( _ ) ) and
49+ not ( m .getScope ( ) . getShortName ( ) = "__init__" and exists ( m .getScope ( ) .getPackage ( ) .getSubModule ( exported_name ) ) ) and
50+ not exists ( ImportStarNode imp | imp .getEnclosingModule ( ) = m .getScope ( ) | imp .getModule ( ) .pointsTo ( ) . isAbsent ( ) ) and
5151not mutates_globals ( m )
5252select name , "The name '" + exported_name + "' is exported by __all__ but is not defined."
0 commit comments