Skip to content

Commit a1a1218

Browse files
committed
Python: Ignore from foo import * when foo is absent.
1 parent dc5c0f8 commit a1a1218

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

python/ql/src/Imports/UnintentionalImport.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ predicate all_defined(ModuleValue exporter) {
2626
}
2727

2828
from ImportStar imp, ModuleValue exporter
29-
where import_star(imp, exporter) and not all_defined(exporter)
29+
where import_star(imp, exporter) and not all_defined(exporter) and not exporter.isAbsent()
3030
select imp,
3131
"Import pollutes the enclosing namespace, as the imported module $@ does not define '__all__'.",
3232
exporter, exporter.getName()
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
| imports_test.py:22:1:22:32 | from module_without_all import * | Import pollutes the enclosing namespace, as the imported module $@ does not define '__all__'. | module_without_all.py:0:0:0:0 | Module module_without_all | module_without_all |
2-
| imports_test.py:65:1:65:40 | from module_that_does_not_exist import * | Import pollutes the enclosing namespace, as the imported module $@ does not define '__all__'. | file://:0:0:0:0 | Missing module module_that_does_not_exist | module_that_does_not_exist |

0 commit comments

Comments
 (0)