Skip to content

Missing return statement" error misfires on with blocks #10961

Closed
@eric-wieser

Description

@eric-wieser

Bug Report

The "Missing return statement" error misfires on with blocks.

To Reproduce

Create the following python file:

import contextlib

def foo() -> int:
	with contextlib.ExitStack() as stack:
		return 2

Run mypy:

Expected Behavior

There should be no error

Actual Behavior

this_issue.py:3: error: Missing return statement
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 0.910
  • Python version used: 3.8
  • Operating system and version: Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions