Skip to content

--warn-no-return Warns about functions that have no return statements if used in tandem with --strict-optional #2370

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
rowillia opened this issue Oct 28, 2016 · 3 comments

Comments

@rowillia
Copy link
Contributor

rowillia commented Oct 28, 2016

UPDATED - This problem appears to happen when --warn-no-return is used in tandem with --strict-optional

test.py:

class Foo():
    def __init__(self) -> None:
        self.x = 0
    def increment_x(self) -> None:
        self.x += 1

mypy -s --fast-parser --warn-no-return --strict-optional test.py

test.py: note: In member "__init__" of class "Foo":
test.py:2: note: Missing return statement
test.py: note: In member "increment_x" of class "Foo":
test.py:4: note: Missing return statement
@rwbarton
Copy link
Contributor

This is just a bug caused by the fact that --strict-optional changes the meaning of returning None internally in mypy. It works fine without --strict-optional.

@rowillia rowillia changed the title --warn-no-return Warns about functions that have no return statements --warn-no-return Warns about functions that have no return statements if used in tandem with --strict-optional Oct 28, 2016
@rowillia
Copy link
Contributor Author

Got it. Thanks @rwbarton for figuring out what I meant even though I forgot to specify what my flags were. Changed the title to reflect the actual problem.

@ddfisher
Copy link
Collaborator

So really this is just a problematic interaction between --warn-no-return and --strict-optional.

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

3 participants