question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WPS440/441 on multiple loops

See original GitHub issue

With code like:

        for widget in self._widgets:
            await widget.update()
        ...
        for widget in self._widgets:
            await widget.set_something(state)

I get WPS440 and WPS441 due to reusing the widget variable name in the second loop.

I think that WPS441 shouldn’t apply, as we are defining a new variable, as opposed to reusing the previous value from the last loop.

Then I think also, that WPS440 shouldn’t apply, as the WPS441 stops you from reusing the first variable anyway, so shadowing a variable you’re not supposed to be using is not an issue. i.e. If WPS441 is going to make you treat them as block-scoped variables, then shadowing them shouldn’t be taken into account as they shouldn’t be treated as being in the enclosing scope.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

4reactions
sobolevncommented, Jun 24, 2021

Reproduction:

async def some():
    for widget in self._widgets:
        await widget.update()

    for widget in self._widgets:
        await widget.set_something(state)

Снимок экрана 2021-06-24 в 19 14 09
1reaction
sobolevncommented, Nov 10, 2020

Awesome! Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I break out of multiple loops? - Stack Overflow
My first instinct would be to refactor the nested loop into a function and use return to break out.
Read more >
Play multiple loops (in succession) - Anytune Help Center
Let's say you have several sections of a song that you want to practice in one go. There are a couple different approaches:...
Read more >
How to perform multiple loops - Designer - Alteryx Community
Hello All, I need help to solve below problem using alteryx: Holdings Combined key CP/DV/MT Amount Net Amount net amount fke Sum of...
Read more >
Breaking/continuing out of multiple loops - Ideas
Hi! SUGGESTION An easy way to break/continue within nested loops. MY REAL LIFE EXAMPLE I am looping through a list of basketball players, ......
Read more >
How to Break out of multiple loops in Python ? - GeeksforGeeks
A direct approach to this problem is to iterate through all the elements of arr using a for loop and to use a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found