Skip to content

Implicit None return value is not type checked #6687

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

Closed
suutari-ai opened this issue Apr 17, 2019 · 2 comments
Closed

Implicit None return value is not type checked #6687

suutari-ai opened this issue Apr 17, 2019 · 2 comments

Comments

@suutari-ai
Copy link

I think this is a bug in Mypy. Mypy doesn't seem to check the type of the implicit None return value of a function which doesn't have a return statement.

$ cat foo.py 
def foo() -> str:
    pass
$ mypy --strict foo.py
  • What is the actual behavior/output?

No errors reported.

  • What is the behavior/output you expect?
foo.py:2: error: Incompatible return value type (got "None", expected "str")
  • What are the versions of mypy and Python you are using?

mypy 0.701
Python 3.6.5

  • Do you see the same issue after installing mypy from Git master?

Haven't tested.

  • What are the mypy flags you are using? (For example --strict-optional)

--strict

@ilevkivskyi
Copy link
Member

Empty (trivial) function bodies are special, see #2350.

You can try adding something else there to see an error about missing return statement.

@suutari-ai
Copy link
Author

Ah, I see. Thanks for the info!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants