Skip to content

Commit 717490b

Browse files
authored
Merge pull request #2265 from tausbn/python-fix-unused-import-global-name-used-join-order
Approved by RasmusWL
2 parents 5b00b21 + 4314808 commit 717490b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

python/ql/src/Imports/UnusedImport.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
import python
1414
import Variables.Definition
1515

16-
predicate global_name_used(Module m, Variable name) {
16+
predicate global_name_used(Module m, string name) {
1717
exists(Name u, GlobalVariable v |
1818
u.uses(v) and
19-
v.getId() = name.getId() and
19+
v.getId() = name and
2020
u.getEnclosingModule() = m
2121
)
2222
or
2323
// A use of an undefined class local variable, will use the global variable
2424
exists(Name u, LocalVariable v |
2525
u.uses(v) and
26-
v.getId() = name.getId() and
26+
v.getId() = name and
2727
u.getEnclosingModule() = m and
2828
not v.getScope().getEnclosingScope*() instanceof Function
2929
)
@@ -101,7 +101,7 @@ predicate unused_import(Import imp, Variable name) {
101101
not imp.getAnImportedModuleName() = "__future__" and
102102
not imp.getEnclosingModule().declaredInAll(name.getId()) and
103103
imp.getScope() = imp.getEnclosingModule() and
104-
not global_name_used(imp.getScope(), name) and
104+
not global_name_used(imp.getScope(), name.getId()) and
105105
// Imports in `__init__.py` are used to force module loading
106106
not imp.getEnclosingModule().isPackageInit() and
107107
// Name may be imported for use in epytext documentation

0 commit comments

Comments
 (0)