Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6056b45

Browse files
committed
Python: Autoformat py/iter-returns-non-iterator
1 parent 1c79ec5 commit 6056b45

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

python/ql/src/Functions/IterReturnsNonIterator.ql

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@
1212

1313
import python
1414

15-
FunctionObject iter_method(ClassObject t) {
16-
result = t.lookupAttribute("__iter__")
17-
}
15+
FunctionObject iter_method(ClassObject t) { result = t.lookupAttribute("__iter__") }
1816

19-
cached ClassObject return_type(FunctionObject f) {
17+
cached
18+
ClassObject return_type(FunctionObject f) {
2019
exists(ControlFlowNode n, Return ret |
21-
ret.getScope() = f.getFunction() and ret.getValue() = n.getNode() and
20+
ret.getScope() = f.getFunction() and
21+
ret.getValue() = n.getNode() and
2222
n.refersTo(_, result, _)
2323
)
2424
}
2525

2626
from ClassObject t, FunctionObject iter
27-
where exists(ClassObject ret_t | iter = iter_method(t) and
28-
ret_t = return_type(iter) and
29-
not ret_t.isIterator()
30-
)
31-
32-
select iter, "The '__iter__' method of iterable class $@ does not return an iterator.", t, t.getName()
27+
where
28+
exists(ClassObject ret_t |
29+
iter = iter_method(t) and
30+
ret_t = return_type(iter) and
31+
not ret_t.isIterator()
32+
)
33+
select iter, "The '__iter__' method of iterable class $@ does not return an iterator.", t,
34+
t.getName()

0 commit comments

Comments
 (0)