You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No error for implicitly defined return value #1869
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, Strings, or primitive data types, for instance:
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:
deff() ->int:
print('Hw')
We should address this when introducing --strict-optional (which is currently experimental).
Activity
gvanrossum commentedon Jul 15, 2016
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:
We should address this when introducing
--strict-optional(which is currently experimental).gvanrossum commentedon Jul 15, 2016
See also #1748 which adds a new flag that would check for this kind of error (but still not in unannotated functions).
rwbarton commentedon Oct 7, 2016
Perhaps the OP is more interested in something like
--disallow-untyped-defs.gvanrossum commentedon Oct 7, 2016
Then again maybe this can be labeled as a question and closed?
ddfisher commentedon Oct 24, 2016
#1748 has landed, so I'm going to close this.