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

Detect possible simplifications using walrus #9532

Closed
sam-s opened this issue Apr 2, 2024 · 1 comment
Closed

Detect possible simplifications using walrus #9532

sam-s opened this issue Apr 2, 2024 · 1 comment
Labels
Invalid Not a bug, already exists or already fixed

Comments

@sam-s
Copy link

sam-s commented Apr 2, 2024

Current problem

Here is the code that should be flagged by a walrus checker:

foo = ....
if foo:
    ....

the better code is

if foo := ...:
    ...

Desired solution

there should be a "code review" checker that flags code where

  • a variable is set and
  • its value is immediately checked and
  • is is not used if the check fails

Additional context

No response

@sam-s sam-s added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Apr 2, 2024
@Pierre-Sassoulas
Copy link
Member

Sound like https://pylint.readthedocs.io/en/stable/user_guide/messages/refactor/consider-using-assignment-expr.html, you need to activate the code style checker:

[MAIN]
py-version=3.8
load-plugins=pylint.extensions.code_style

@Pierre-Sassoulas Pierre-Sassoulas added Invalid Not a bug, already exists or already fixed and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Invalid Not a bug, already exists or already fixed
Projects
None yet
Development

No branches or pull requests

2 participants