-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Return value expected on def f() -> Optional[Type]: with plain return #1003
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
Actually this is intentional -- it's a code smell and even called out in PEP 8 (https://www.python.org/dev/peps/pep-0008/#programming-recommendations, "Be consistent in return statements.") |
Thanks for explaining this @gvanrossum . I've read pep8 several times before but didn't quite follow this specific recommendation, moreover pep8 command does not complain (at least my version) about this. |
Sadly the pep8 tool's name is an insult to the intentions of the PEP 8
document.
|
I'm all for eliminating code smells, but I just struggled with this error a bit because I'm not in the state of mind to fix pep8 stuff when I run mypy. I'd suggest removing this warning since it isn't about typing. If the function returns None and that's what the signature calls for, then mypy shouldn't complain otherwise. |
mypy is expecting me to explicitly
return None
instead ofreturn
, but I'd expect that to be inferred as there's little point in me telling it i return NoneThe text was updated successfully, but these errors were encountered: