-
Notifications
You must be signed in to change notification settings - Fork 756
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
Conversation
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: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
testsuite/python38.py
Outdated
@@ -53,3 +53,5 @@ def f3( | |||
#: E221:1:6 E221:1:19 | |||
if (x := 1) == (y := 2): | |||
pass | |||
#: E741 | |||
while l := thing: |
There was a problem hiding this comment.
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
013e07b
to
a131316
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pycodestyle 2.11 no longer reports E741 - ambiguous variable name for `if l == True` because it doesn't contain an assignment. PyCQA/pycodestyle#1118
* 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
Noted from #959 (comment) -- we needed to limit this check to assignment operators specifically