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

Feature request: Local variable never read #13541

Open
alippai opened this issue Sep 27, 2024 · 0 comments
Open

Feature request: Local variable never read #13541

alippai opened this issue Sep 27, 2024 · 0 comments
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule

Comments

@alippai
Copy link

alippai commented Sep 27, 2024

It'd be useful to track if a local variable was read before assigned again:

def main():
  x = 5
  x = 6
  print(x)

A common use-case is simply typos or using if instead of elif:

if case1:
  x = 1
if case2:
  x = 2
else:
  x = 3

Where x = 1 is never used.
The correct snippet after fixing the mistake would be:

if case1:
  x = 1
elif case2:
  x = 2
else:
  x = 3
@AlexWaygood AlexWaygood added rule Implementing or modifying a lint rule needs-decision Awaiting a decision from a maintainer labels Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

2 participants