-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
pointless comparison hint is frequently very off base #12617
Comments
Makes sense to me. We can probably improve the message over all. |
FWIW, I don't think that's the assumption the rule is making when it says "Did you mean to assign a value?". Instead, I think the rule is assuming that the user meant to write something like def is_some(n):
x = n is not None or GLOBAL_OBJECT = ...
def is_some(n):
GLOBAL_OBJECT.x = n is not None As a general rule, to me it seems more likely that someone made a typo than that they misunderstood the fundamentals of Python semantics (thinking that Python has implicit returns when it does not). But I think you're right that if it's the last line of the function, the more likely typo is that they forgot to use a TL;DR: I'd also accept a PR making the error message adaptive here depending on whether it's the last line of a function or not 😄 |
missing the entire left-hand side is a pretty big typo, and python is very frequently used by beginner programmers and programmers who do not usually specialize in python (like me, i'm mostly a rust programmer, but i know just enough python to get by with basic tweaks) |
@MichaReiser @AlexWaygood looks like this one is up for grabs - would like to give it a shot (first time contributor here :) |
nevermind - missed this |
code (playground):
here, the user is trying to do an implicit return, but python does not have implicit returns. the hint given is this:
the chance of someone meaning to write
=
and instead writingis not
is approximately zero. if a pointless comparison appears at the end of a function, it should suggest returning it instead of suggestingassert
, and the assignment suggestion should only appear if the operator contains=
.The text was updated successfully, but these errors were encountered: