-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Give a warning if a local variable is assigned to but never read #76
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
Comments
@JukkaL Do you mean something like this: def foo(x:int) -> int:
x = 5
y = 5
return x ,in this y maybe misspelled local variable which is assigned to but never read. |
@dubesar Yeah! Or something like this: def thing() -> str:
processor = 'default'
if cond():
processsor = 'extra' # Note misspelling -- extra 's'
return processor |
Hi @JukkaL, |
@sudhirkumar43 Can you rephrase your question? I wasn't quite sure what you mean exactly. |
@JukkaL |
It would be sufficient to give a message such as |
@JukkaL |
@JukkaL, I have been dealing with a similar issue with Refurb (see comment), curious what your thoughts are on the following: This currently passes in Mypy, and this issue proposes that a warning should be emitted: x = 123 # WARN: value unused
x = 456 This, I believe is similar in nature, but gives a type error instead: x = 123 # value is still unused here
x = "abc" # but you get a type error here
Adding x = 123
print(x)
x = "abc" A few thoughts:
|
The type checker should give a warning if a local variable is only assigned to but never read.
This is usually a result of a misspelled variable name.
Perhaps only do this if warnings have been explicitly enabled using a command line option or via some other mechanism.
The text was updated successfully, but these errors were encountered: