Skip to content

Commit 1f76284

Browse files
committed
Python: In py/import-own-module handle from foo import *
1 parent 5cc2efe commit 1f76284

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

python/ql/src/Imports/ModuleImportsItself.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import python
1414

15-
predicate modules_imports_itself(Import i, ModuleValue m) {
15+
predicate modules_imports_itself(ImportingStmt i, ModuleValue m) {
1616
i.getEnclosingModule() = m.getScope() and
1717
m = max(string s, ModuleValue m_ |
1818
s = i.getAnImportedModuleName() and
@@ -22,6 +22,6 @@ predicate modules_imports_itself(Import i, ModuleValue m) {
2222
)
2323
}
2424

25-
from Import i, ModuleValue m
25+
from ImportingStmt i, ModuleValue m
2626
where modules_imports_itself(i, m)
2727
select i, "The module '" + m.getName() + "' imports itself."

python/ql/test/query-tests/Imports/PyCheckerTests/ModuleImportsItself.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
| pkg_notok/__init__.py:4:1:4:16 | Import | The module 'pkg_notok' imports itself. |
33
| pkg_notok/__init__.py:12:1:12:25 | Import | The module 'pkg_notok' imports itself. |
44
| pkg_notok/__init__.py:13:1:13:37 | Import | The module 'pkg_notok' imports itself. |
5+
| pkg_notok/__init__.py:14:1:14:23 | from pkg_notok import * | The module 'pkg_notok' imports itself. |

python/ql/test/query-tests/Imports/PyCheckerTests/pkg_notok/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class Foo(object):
1111

1212
from pkg_notok import Foo
1313
from pkg_notok import Foo as NotOkFoo
14-
from pkg_notok import * # TODO: TN
14+
from pkg_notok import *

0 commit comments

Comments
 (0)