Skip to content

Erroneous "missing return statement" using ExitStack #7726

Closed as not planned
Closed as not planned
@wadetregaskis-linkedin

Description

@wadetregaskis-linkedin

test.py:

from contextlib import ExitStack

def context_manager_with_return_bug() -> int:
    with ExitStack() as stack:
        return 5

mypy complains: test.py:3: error: Missing return statement

Oddly this only seems to happen when using ExitStack specifically - no other context manager, based on other functions / classes / etc, in my codebase triggers this bug.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions