-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
No error for implicitly defined return value #1869
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
Well, one of mypy's fundamental properties is that it doesn't complain about a function that has no annotations. So it really should not complain about the second example (g()) above. However the following also is not considered an error, and this is indeed troubling: def f() -> int:
print('Hw') We should address this when introducing |
See also #1748 which adds a new flag that would check for this kind of error (but still not in unannotated functions). |
Perhaps the OP is more interested in something like |
Then again maybe this can be labeled as a question and closed? |
#1748 has landed, so I'm going to close this. |
Correct me if this issue has already been addressed, but I found the no error for an implicitly defined return value troubling. It seems as if this would not be static typing because the return value should explicitly defined (whatever it is) for statically typed languages.
I think there should be a difference between these two functions when run through the parser, in that the second one should raise an error for not having an explicitly defined return value:
In statically typed languages like Java, return values must be explicitly defined, whether they are
void
,String
s, or primitive data types, for instance:The text was updated successfully, but these errors were encountered: