New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WPS440/441 on multiple loops #1416
Comments
Another example of the same issue with try:
sqs_response = self.client.send_message(
QueueUrl=self.url,
MessageBody=message_body,
)
except self.client.exceptions.QueueDoesNotExist as err:
raise SQSQueueDoesNotExist(queue=self) from err
except self.client.exceptions.ClientError as err:
if self._error_code_is(err, 'InvalidParameterValue'):
raise MessageTooLarge(
max_supported_size=MAX_MESSAGE_SIZE,
message_body=message_body,
) cause 440 and 441:
|
Hello, @Elton-Lin and I would like to work on fixing this. Thanks! |
Awesome! Thanks! |
We believe that the issue with the except blocks is fixed in this issue: |
@sobolevn Should we work on modifying both rules WPS 440/441 so that they don't trigger on multiple for loops? |
Yes, @huangyunzen, please! |
WPS441 also applies to "with blocks" in addition to the for blocks mentioned in the issue - should we fix them too? |
Yes, please 👍 |
@sobolevn Is it possible to separate this issue into two issues? We are done with fixing WPS441, but WPS440 might take some more time and we were wondering if we can submit a pull request now for only 441. |
I can always accept a PR with a partial fix! 👍 |
Done! |
Can this ticket be reopened? I'm still getting a for widget in self._widgets:
await widget.update()
...
for widget in self._widgets:
await widget.set_something(state) |
Any updates? |
If the first loop is a proper loop and the second loop if a comprehension, WPS441 is raised in the comprehension variable:
|
This raises an |
With code like:
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.
The text was updated successfully, but these errors were encountered: