File tree Expand file tree Collapse file tree
src/semmle/python/objects
test/library-tests/modules/usage Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -210,7 +210,12 @@ class ModuleValue extends Value {
210210 i .getTest ( ) .( Compare ) .compares ( name , op , main ) and
211211 name .getId ( ) = "__name__" and main .getText ( ) = "__main__"
212212 )
213- // TODO: Add she-bang handling
213+ or
214+ exists ( Comment c |
215+ c .getLocation ( ) .getFile ( ) = this .getPath ( ) and
216+ c .getLocation ( ) .getStartLine ( ) = 1 and
217+ c .getText ( ) .regexpMatch ( "^#!/.*python(2|3)?[ \\\\t]*$" )
218+ )
214219 )
215220 }
216221}
Original file line number Diff line number Diff line change 22| file://:0:0:0:0 | Module sys | isUsedAsModule |
33| imported.py:0:0:0:0 | Module imported | isUsedAsModule |
44| main.py:0:0:0:0 | Module main | isUsedAsScript |
5- | myscript.py:0:0:0:0 | Script myscript | <UNKNOWN> |
5+ | myscript.py:0:0:0:0 | Script myscript | isUsedAsScript |
66| script:0:0:0:0 | Script script | isUsedAsScript |
You can’t perform that action at this time.
0 commit comments