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

False positive superfluous-parens with walrus operator #4346

Closed
otchita opened this issue Apr 12, 2021 · 0 comments · Fixed by #4784
Closed

False positive superfluous-parens with walrus operator #4346

otchita opened this issue Apr 12, 2021 · 0 comments · Fixed by #4784
Labels
Assignment expression Related to the walrus operator / assignment expression False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@otchita
Copy link

otchita commented Apr 12, 2021

I've came across a superfluous-parens false positive when using the walrus operator:

Steps to reproduce

Given a file test.py:

"""Test example."""
if (var := 3) in [1, 2, 3]:
    print('Hello world !')

We obtain the following:

Current behavior

Result of pylint test.py:

************* Module test
test.py:2:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens)

Expected behavior

Normally, this should not raise any errors as the use of parentheses here is relevant. Because, otherwise the value of var will be the inclusion boolean instead of the value itself.

pylint --version output

Result of pylint --version output on my local macOS:

pylint 2.7.4
astroid 2.5.2
Python 3.8.8 (v3.8.8:024d8058b0, Feb 19 2021, 08:48:17) 
[Clang 6.0 (clang-600.0.57)]
@Pierre-Sassoulas Pierre-Sassoulas added the False Positive 🦟 A message is emitted but nothing is wrong with the code label Apr 14, 2021
@hippo91 hippo91 added the Assignment expression Related to the walrus operator / assignment expression label May 13, 2021
DanielNoord added a commit to DanielNoord/pylint that referenced this issue Aug 1, 2021
This fixes the false positives identified in pylint-dev#2818, pylint-dev#3249, pylint-dev#3608 & pylint-dev#4346
All false positives reported fell under keywords before walrus operator
or if-keyword within generators/comprehension.
This closes pylint-dev#2818, closes pylint-dev#3429, closes pylint-dev#3608, closes pylint-dev#4346
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.10.0 milestone Aug 1, 2021
DanielNoord added a commit to DanielNoord/pylint that referenced this issue Aug 1, 2021
This fixes the false positives identified in pylint-dev#2818, pylint-dev#3249, pylint-dev#3608 & pylint-dev#4346
All false positives reported fell under keywords before walrus operator
or if-keyword within generators/comprehension.
This closes pylint-dev#2818, closes pylint-dev#3429, closes pylint-dev#3608, closes pylint-dev#4346
DanielNoord added a commit to DanielNoord/pylint that referenced this issue Aug 1, 2021
This fixes the false positives identified in pylint-dev#2818, pylint-dev#3249, pylint-dev#3608 & pylint-dev#4346
All false positives reported fell under keywords before walrus operator
or if-keyword within generators/comprehension.
This closes pylint-dev#2818, closes pylint-dev#3429, closes pylint-dev#3608, closes pylint-dev#4346
Pierre-Sassoulas added a commit that referenced this issue Aug 3, 2021
* Split functional tests for ``superfluous-parents``

* Fix false positives for superfluous-parens
This fixes the false positives identified in #2818, #3249, #3608 & #4346
All false positives reported fell under keywords before walrus operator
or if-keyword within generators/comprehension.
This closes #2818, closes #3429, closes #3608, closes #4346

* Move the superfluous functional tests to functional/s/super

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Assignment expression Related to the walrus operator / assignment expression False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants