Skip to content

Python: Port NonIteratorInForLoop.ql#21688

Draft
tausbn wants to merge 2 commits intomainfrom
tausbn/python-port-non-iterator-in-for-loop
Draft

Python: Port NonIteratorInForLoop.ql#21688
tausbn wants to merge 2 commits intomainfrom
tausbn/python-port-non-iterator-in-for-loop

Conversation

@tausbn
Copy link
Copy Markdown
Contributor

@tausbn tausbn commented Apr 9, 2026

Uses the DuckTyping module to approximate whether something is likely
to be an iterator or not.

We lose one test result due to the fact that we don't know what to do
about for ... in 1 (because 1 is an instance of a built-in). I'm
going to defer addressing this until we get some modelling of built-in
types.

Uses the `DuckTyping` module to approximate whether something is likely
to be an iterator or not.

We lose one test result due to the fact that we don't know what to do
about `for ... in 1` (because `1` is an instance of a built-in). I'm
going to defer addressing this until we get some modelling of built-in
types.
@tausbn tausbn added the no-change-note-required This PR does not need a change note label Apr 9, 2026
@github-actions github-actions bot added the Python label Apr 9, 2026
A common pattern is to check `isinstance(it, (list, tuple))` before
proceeding with the iteration.
@tausbn tausbn force-pushed the tausbn/python-port-non-iterator-in-for-loop branch from 9ad28d0 to 8fdf5c9 Compare April 9, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant