Skip to content

Always complain if returning a value if annotated to return None #1509

Open
@JukkaL

Description

@JukkaL

Mypy doesn't complain about this code that returns a value in a function declared to return None, since the return value is Any:

def f() -> None:
    return g()   # oops, but no error

def g():
    return 1

I think that mypy could complain about the return statement even if the value has type Any. The current behavior is not inconsistent or incorrect, but probably not optimal.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions