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
Note that the function foo has an implicit Any return type, which is likely not what the programmer intended.
Add a new error code (disabled by default since this is a backward compatibility break) that generates an error about a missing return type if at least one argument has an explicit type annotation. The error could be something like 'Function "foo" has no return type annotation', and perhaps add a note suggesting the use of -> None if the function never returns a value.
We might eventually enable the error code by default as part of a major mypy release, such as 2.0 or 3.0.
The text was updated successfully, but these errors were encountered:
Adding optional error flag for missing return type, when a function has at least one typed argument. This will address issue python#15127
Co-Authored-By: Leonardo Abreu Santos <31524775+saintleonar@users.noreply.github.com>
@JukkaL Hi. Isn't this already the way mypy behaves when the flag --disallow-incomplete-defs is used? For example, if I run mypy --disallow-incomplete-defs example.py on this file
# example.pydeffoo(x: str):
return123
I get
example.py:2: error: Function is missing a return type annotation [no-untyped-def]
Found 1 error in 1 file (checked 1 source file)
It's pretty common to see functions like this:
Note that the function
foo
has an implicitAny
return type, which is likely not what the programmer intended.Add a new error code (disabled by default since this is a backward compatibility break) that generates an error about a missing return type if at least one argument has an explicit type annotation. The error could be something like 'Function "foo" has no return type annotation', and perhaps add a note suggesting the use of
-> None
if the function never returns a value.We might eventually enable the error code by default as part of a major mypy release, such as 2.0 or 3.0.
The text was updated successfully, but these errors were encountered: