Skip to content

Commit 9f40884

Browse files
committed
Python: Modernise py/local-shadows-builtin
+ moved `scope instanceof Function` so it makes more sense :)
1 parent 6a73479 commit 9f40884

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

python/ql/src/Variables/ShadowBuiltin.ql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
* @precision medium
1212
* @id py/local-shadows-builtin
1313
*/
14-
14+
1515
import python
1616
import Shadowing
17-
17+
import semmle.python.types.Builtins
18+
1819
predicate white_list(string name) {
1920
/* These are rarely used and thus unlikely to be confusing */
2021
name = "iter" or
@@ -43,10 +44,11 @@ predicate white_list(string name) {
4344
}
4445

4546
predicate shadows(Name d, string name, Scope scope, int line) {
46-
exists(LocalVariable l | d.defines(l) and scope instanceof Function and
47+
exists(LocalVariable l | d.defines(l) and
4748
l.getId() = name and
48-
exists(Object::builtin(l.getId()))
49+
exists(Builtin::builtin(l.getId()))
4950
) and
51+
scope instanceof Function and
5052
d.getScope() = scope and
5153
d.getLocation().getStartLine() = line and
5254
not white_list(name) and

0 commit comments

Comments
 (0)