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

Fix false positive with E741 #1118

Merged
merged 1 commit into from Nov 6, 2022
Merged

Conversation

dannysepler
Copy link
Contributor

Noted from #959 (comment) -- we needed to limit this check to assignment operators specifically

pycodestyle.py Outdated
E741: except AttributeError as O:
E741: with lock as l:
E741: global I
E741: nonlocal l
E741: def foo(l):
E741: def foo(l=12):
E741: l = foo(l=12)
E741: while l := thing:
Copy link
Member

Choose a reason for hiding this comment

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

you'll have to put this in the versioned test file rather than the docstring

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wow, super speedy. you're right, one sec

Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need the condition you've added -- := will never appear as a token in 3.7

Copy link
Contributor Author

Choose a reason for hiding this comment

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

100%, i was barking up the wrong tree

@@ -53,3 +53,5 @@ def f3(
#: E221:1:6 E221:1:19
if (x := 1) == (y := 2):
pass
#: E741
while l := thing:
Copy link
Member

Choose a reason for hiding this comment

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

should probably make this valid syntax as well while you're at it

Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

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

@asottile asottile merged commit c14a263 into PyCQA:main Nov 6, 2022
bkeryan added a commit to bkeryan/python-styleguide that referenced this pull request Oct 5, 2023
pycodestyle 2.11 no longer reports E741 - ambiguous variable name for
`if l == True` because it doesn't contain an assignment.

PyCQA/pycodestyle#1118
mshafer-NI pushed a commit to ni/python-styleguide that referenced this pull request Oct 9, 2023
* pyproject.toml: Upgrade flake8 and pycodestyle for Python 3.12

* Update poetry.lock

* config: Move inline comments to separate lines for compatibility with flake8 >=6.0

* Coding-Conventions.md: Update E721 example

With pycodestyle 2.11, comparing types with `is` is no longer an error:
PyCQA/pycodestyle#1084

* tests: Update structural_tests to pass with pycodestyle 2.9 and 2.11

pycodestyle 2.11 no longer reports E741 - ambiguous variable name for
`if l == True` because it doesn't contain an assignment.

PyCQA/pycodestyle#1118

* PR workflow: Test with Python 3.12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants