Skip to content

Commit dd33f4f

Browse files
tausbnyoff
andauthored
Python: Apply suggestions from code review
Co-authored-by: yoff <[email protected]>
1 parent 7f44ceb commit dd33f4f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ module ImportStar {
1515
s = n.getScope().getEnclosingScope*() and
1616
exists(potentialImportStarBase(s)) and
1717
// Not already defined in an enclosing scope.
18-
not isDefinedLocally(n, name)
18+
not isDefinedLocally(n)
1919
}
2020

2121
/** Holds if `n` refers to a variable that is defined in the module in which it occurs. */
22-
private predicate isDefinedLocally(NameNode n, string name) {
22+
private predicate isDefinedLocally(NameNode n) {
2323
// Defined in an enclosing scope
24-
exists(LocalVariable v | v.getId() = name and v.getScope() = n.getScope().getEnclosingScope*())
24+
exists(LocalVariable v | v.getId() = n.getId() and v.getScope() = n.getScope().getEnclosingScope*())
2525
or
2626
// Defined as a built-in
27-
name = Builtins::getBuiltinName()
27+
n.getId() = Builtins::getBuiltinName()
2828
or
2929
// Defined as a global in this module
30-
globalNameDefinedInModule(name, n.getEnclosingModule())
30+
globalNameDefinedInModule(n.getId(), n.getEnclosingModule())
3131
or
3232
// A non-built-in that still has file-specific meaning
33-
name in ["__name__", "__package__"]
33+
n.getId() in ["__name__", "__package__"]
3434
}
3535

3636
/** Holds if a global variable called `name` is assigned a value in the module `m`. */
@@ -50,7 +50,7 @@ module ImportStar {
5050
predicate importStarResolvesTo(NameNode n, Module m) {
5151
m = getStarImported+(n.getEnclosingModule()) and
5252
globalNameDefinedInModule(n.getId(), m) and
53-
not isDefinedLocally(n, n.getId())
53+
not isDefinedLocally(n)
5454
}
5555

5656
/**

0 commit comments

Comments
 (0)