-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Optional error code to flag missing return type when an argument has an annotation #15127
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
Look at the code paths for |
Is this issue already been resolved? |
Is this issue solved..? |
joaopedro-s
added a commit
to joaopedro-s/mypy
that referenced
this issue
Jul 1, 2023
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 <[email protected]>
@JukkaL Hi. Isn't this already the way mypy behaves when the flag # example.py
def foo(x: str):
return 123 I get
|
Is this issue solved? If not, can I work on it? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: