-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
False warning: Returning Any from function declared to return "bool" #5697
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
Why do you think the warning is false? It looks like a totally reasonable warning, since |
because |
Everything applied to |
This was helpful. Thank you! |
I get the same error when using: def verify_password(plain_password :str, hashed_password :str) -> bool:
return pwd_context.verify(plain_password, hashed_password) Which is taken from the FastAPI docs. In this case I think I understand the rules of the In any case, the fix is simple enough: def verify_password(plain_password :str, hashed_password :str) -> bool:
return bool(pwd_context.verify(plain_password, hashed_password)) But it feels excessive to enforce one additional function call per call stack to please mypy, even in |
@Torxed the fix seems simple here: mypy needs to be told what the return type of I would not recommend turning on the option that generates this error. It's too strict to be useful for most code. |
|
Not all elements from the event dict are sure to be something that can be evaluated See e.g.: python/mypy#5697
* Typing: events.py * Remove unused variable * Fix return Any from return statement Not all elements from the event dict are sure to be something that can be evaluated See e.g.: python/mypy#5697 * Sort out Event disambiguity There was a name collision of multiprocessing Event type and frigate events Co-authored-by: Sebastian Englbrecht <[email protected]>
same issue here 👋 My little hack for this is to set a new variable, and type the variable. (Similar to @Torxed, but not explicitly casting) from typing import Any
class Structure():
def __eq__(self, other: Any) -> bool:
outcome: bool = {} == other
return outcome |
The same problem affects me. It is evident that |
It's actually not completely evident. Because the But to the best of my understanding, passlib simply lacks native annotation in all possible And to the best of my understanding, Would be nice if the project moved to https://pypi.org/project/sphinx-autodoc-typehints/ or something similar. |
@Torxed Thank you for your thoughtful explanations, as I had not given this topic much thought. |
mypytest.py:5: warning: Returning Any from function declared to return "bool"
mypy==0.630
--strict
The text was updated successfully, but these errors were encountered: