Python: In py/import-own-module handle from foo import *

This commit is contained in:
Rasmus Wriedt Larsen
2020-02-11 11:42:40 +01:00
parent 5cc2efef8e
commit 1f762841ec
3 changed files with 4 additions and 3 deletions

View File

@@ -12,7 +12,7 @@
import python
predicate modules_imports_itself(Import i, ModuleValue m) {
predicate modules_imports_itself(ImportingStmt i, ModuleValue m) {
i.getEnclosingModule() = m.getScope() and
m = max(string s, ModuleValue m_ |
s = i.getAnImportedModuleName() and
@@ -22,6 +22,6 @@ predicate modules_imports_itself(Import i, ModuleValue m) {
)
}
from Import i, ModuleValue m
from ImportingStmt i, ModuleValue m
where modules_imports_itself(i, m)
select i, "The module '" + m.getName() + "' imports itself."

View File

@@ -2,3 +2,4 @@
| pkg_notok/__init__.py:4:1:4:16 | Import | The module 'pkg_notok' imports itself. |
| pkg_notok/__init__.py:12:1:12:25 | Import | The module 'pkg_notok' imports itself. |
| pkg_notok/__init__.py:13:1:13:37 | Import | The module 'pkg_notok' imports itself. |
| pkg_notok/__init__.py:14:1:14:23 | from pkg_notok import * | The module 'pkg_notok' imports itself. |

View File

@@ -11,4 +11,4 @@ import pkg_notok.bar
from pkg_notok import Foo
from pkg_notok import Foo as NotOkFoo
from pkg_notok import * # TODO: TN
from pkg_notok import *