Skip to content

Commit b45743b

Browse files
authored
Merge pull request github#6312 from tausbn/python-deprecate-importnode
Python: Deprecate `importNode`
2 parents 27f2d41 + 1ab8689 commit b45743b

File tree

20 files changed

+15
-82
lines changed

20 files changed

+15
-82
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
lgtm,codescanning
2+
* The `importNode` predicate from the data-flow library has been deprecated. In its place, we
3+
recommend using the API graphs library, accessible via `import semmle.python.ApiGraphs`.
4+

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowUtil.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ predicate localFlowStep(Node nodeFrom, Node nodeTo) { simpleLocalFlowStep(nodeFr
1818
predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }
1919

2020
/**
21+
* DEPRECATED. Use the API graphs library (`semmle.python.ApiGraphs`) instead.
22+
*
23+
* For a drop-in replacement, use `API::moduleImport(name).getAUse()`.
24+
*
2125
* Gets a `Node` that refers to the module referenced by `name`.
2226
* Note that for the statement `import pkg.mod`, the new variable introduced is `pkg` that is a
2327
* reference to the module `pkg`.
@@ -37,7 +41,7 @@ predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }
3741
* `mypkg/foo.py` but the variable `foo` containing `42` -- however, `import mypkg.foo` will always cause `mypkg.foo`
3842
* to refer to the module.
3943
*/
40-
Node importNode(string name) {
44+
deprecated Node importNode(string name) {
4145
exists(Variable var, Import imp, Alias alias |
4246
alias = imp.getAName() and
4347
alias.getAsname() = var.getAStore() and

python/ql/test/experimental/dataflow/import-helper/ImportHelper.expected

Lines changed: 0 additions & 23 deletions
This file was deleted.

python/ql/test/experimental/dataflow/import-helper/ImportHelper.ql

Lines changed: 0 additions & 4 deletions
This file was deleted.

python/ql/test/experimental/dataflow/import-helper/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

python/ql/test/experimental/dataflow/import-helper/mypkg/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

python/ql/test/experimental/dataflow/import-helper/mypkg/bar.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

python/ql/test/experimental/dataflow/import-helper/mypkg/foo.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)