Skip to content
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

Add B020 check to find for-loop control variable overiding iter set #220

Merged
merged 10 commits into from
Jan 27, 2022
Merged

Add B020 check to find for-loop control variable overiding iter set #220

merged 10 commits into from
Jan 27, 2022

Conversation

Korben11
Copy link
Contributor

Description

A simple typo of the for-loop control variable name item => items in loop [items for items in items] can lead to an unintended change of the items variable.

Fixes #219

Copy link
Collaborator

@cooperlees cooperlees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

Just some wording and doc string suggestions.

Please a change log entry please (It's in the README file too).

README.rst Outdated Show resolved Hide resolved
bugbear.py Outdated Show resolved Hide resolved
tests/b020.py Show resolved Hide resolved
tests/test_bugbear.py Outdated Show resolved Hide resolved
tests/b020.py Outdated Show resolved Hide resolved
Korben11 and others added 5 commits January 26, 2022 11:35
Co-authored-by: Cooper Lees <me@cooperlees.com>
Co-authored-by: Cooper Lees <me@cooperlees.com>
Co-authored-by: Cooper Lees <me@cooperlees.com>
Co-authored-by: Cooper Lees <me@cooperlees.com>
Co-authored-by: Cooper Lees <me@cooperlees.com>
Copy link
Collaborator

@cooperlees cooperlees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a line to long - We failed a bugbear check on bugbear! haha

bugbear.py Outdated Show resolved Hide resolved
Korben11 and others added 2 commits January 27, 2022 10:54
Co-authored-by: Cooper Lees <me@cooperlees.com>
Copy link
Collaborator

@cooperlees cooperlees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Will be a good addition as I really dislike this and is an easy typo to make ...

README.rst Outdated Show resolved Hide resolved
Co-authored-by: Cooper Lees <me@cooperlees.com>
@cooperlees cooperlees merged commit f1d1a53 into PyCQA:master Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposed Check: same variable name of list and interating item in for-loop
2 participants