Skip to content

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

Closed

Description

@rowillia

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

Activity

  1. rwbarton commented on Oct 28, 2016

    @rwbarton
    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.

  2. 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[/+] on Oct 28, 2016
  3. rowillia commented on Oct 28, 2016

    @rowillia
    ContributorAuthor

    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.

  4. ddfisher commented on Oct 28, 2016

    @ddfisher
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions