Skip to content

Commit 647b9cd

Browse files
committed
Python: Autoformat query
1 parent 816a8d1 commit 647b9cd

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

python/ql/src/Imports/FromImportOfMutableAttribute.ql

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,25 @@
1010
* @precision medium
1111
* @id py/import-of-mutable-attribute
1212
*/
13+
1314
import python
1415
import semmle.python.filters.Tests
1516

1617
from ImportMember im, ModuleObject m, AttrNode store_attr, string name
17-
where im.getModule().(ImportExpr).getImportedModuleName() = m.getName() and
18-
im.getName() = name and
19-
/* Modification must be in a function, so it can occur during lifetime of the import value */
20-
store_attr.getScope() instanceof Function and
21-
/* variable resulting from import must have a long lifetime */
22-
not im.getScope() instanceof Function and
23-
store_attr.isStore() and
24-
store_attr.getObject(name).refersTo(m) and
25-
/* Import not in same module as modification. */
26-
not im.getEnclosingModule() = store_attr.getScope().getEnclosingModule() and
27-
/* Modification is not in a test */
28-
not store_attr.getScope().getScope*() instanceof TestScope
29-
30-
select im, "Importing the value of '" + name + "' from $@ means that any change made to $@ will be not be observed locally.",
31-
m, "module " + m.getName(), store_attr, m.getName() + "." + store_attr.getName()
18+
where
19+
im.getModule().(ImportExpr).getImportedModuleName() = m.getName() and
20+
im.getName() = name and
21+
/* Modification must be in a function, so it can occur during lifetime of the import value */
22+
store_attr.getScope() instanceof Function and
23+
/* variable resulting from import must have a long lifetime */
24+
not im.getScope() instanceof Function and
25+
store_attr.isStore() and
26+
store_attr.getObject(name).refersTo(m) and
27+
/* Import not in same module as modification. */
28+
not im.getEnclosingModule() = store_attr.getScope().getEnclosingModule() and
29+
/* Modification is not in a test */
30+
not store_attr.getScope().getScope*() instanceof TestScope
31+
select im,
32+
"Importing the value of '" + name +
33+
"' from $@ means that any change made to $@ will be not be observed locally.", m,
34+
"module " + m.getName(), store_attr, m.getName() + "." + store_attr.getName()

0 commit comments

Comments
 (0)