WPS122 should allow a no-op loop var
See original GitHub issueBug report
What’s wrong
Imagine I want to do something 3 times but I don’t care about the attempt number. So I’d normally write something like this:
for _ in range(3):
do_something()
But then the linter complains with WPS122 Found all unused variables definition: _
which is incorrect. While things like assignment allow to fix this with
-_something_unused = get_useless_result()
+get_useless_result()
it is impossible with for-loops not to define this loop variable at all.
How is that should be
This case shouldn’t be a violation of the given rule.
System information
N/A
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top Results From Across the Web
How can I get around declaring an unused variable in a for ...
The special case being loops not using the items of the thing being iterated and the rule being that there's a "target" to...
Read more >tensorflow/control_flow.py at master - autograph - GitHub
get_state/set_state allow piping the mutations through the loop variables as ... self_x = self.x # write self.x back into the loop vars. return...
Read more >For-Loops - Python Numerical Methods
A for-loop assigns the looping variable to the first element of the sequence. It executes everything in the code block. Then it assigns...
Read more >Go: Redefining For Loop Variable Semantics | Hacker News
i would always be equal to 9. With let instead of var, i is properly scoped and the executed script display each increment...
Read more >for loops — Geo-Python site documentation
Loops allow parts of code to be repeated some number of times. ... The variable can be any name you like, and the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is not released. Will be released in
0.15
The same applies for comprehensions.