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 pointless-statement for := operator #7760

Closed
clavedeluna opened this issue Nov 13, 2022 · 2 comments · Fixed by #7763
Closed

False positive pointless-statement for := operator #7760

clavedeluna opened this issue Nov 13, 2022 · 2 comments · Fixed by #7763
Assignees
Labels
Assignment expression Related to the walrus operator / assignment expression False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation

Comments

@clavedeluna
Copy link
Contributor

clavedeluna commented Nov 13, 2022

Bug description

Issue discovered in this PR

# test.py
(walrus := False)
print(walrus)

You can also see this by running

pylint tests/functional/s/superfluous_parens_walrus_py38.py --enable=all

...
tests/functional/s/superfluous_parens_walrus_py38.py:72:0: I0020: Suppressed 'pointless-statement' (from line 2) (suppressed-message)
tests/functional/s/superfluous_parens_walrus_py38.py:73:0: I0020: Suppressed 'pointless-statement' (from line 2) (suppressed-message)
tests/functional/s/superfluous_parens_walrus_py38.py:69:0: I0020: Suppressed 'pointless-statement' (from line 2) (suppressed-message)
tests/functional/s/superfluous_parens_walrus_py38.py:70:0: I0020: Suppressed 'pointless-statement' (from line 2) (suppressed-message)

Once this issue is fixed, please go back and remove pointless-statement in pylint-disable in file tests/functional/s/superfluous_parens_walrus_py38.py

Configuration

No response

Command used

pylint test.py

Pylint output

************* Module test
test.py:1:0: W0104: Statement seems to have no effect (pointless-statement)

------------------------------------------------------------------
Your code has been rated at 5.00/10 (previous run: 5.00/10, +0.00)

Expected behavior

No pointless-statement message in the output.

Pylint version

pylint 2.16.0-dev
astroid 2.12.12
Python 3.11.0 (main, Oct 25 2022, 14:13:24) [Clang 14.0.0 (clang-1400.0.29.202)]

OS / Environment

macOS

Additional dependencies

No response

@clavedeluna clavedeluna added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Nov 13, 2022
@jacobtylerwalls jacobtylerwalls added False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation Assignment expression Related to the walrus operator / assignment expression and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Nov 13, 2022
@cdce8p
Copy link
Member

cdce8p commented Nov 13, 2022

(walrus := False) might technically not be a pointless-statement, it's bad code never the less IMO.
If we remove the warning, we should add a new one for it.

@cdce8p
Copy link
Member

cdce8p commented Nov 13, 2022

Opened #7763 which would add a new named-expr-without-context check.

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 Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants