Skip to content

false-positive return-in-except-star for lambdas #18618

@AI0867

Description

@AI0867

Bug Report

The "return" not allowed in except* block [misc] check introduced in #18123 triggers when a lambda is defined inside an except* block. It does not trigger on nested functions defined in the same place.

To Reproduce

mypy playground

Expected Behavior

I expect mypy to not complain about the presence of return statements if a lambda is present in an except* block.

Actual Behavior

main.py:6: error: "return" not allowed in except* block [misc]
main.py:9: error: "return" not allowed in except* block [misc]
Found 2 errors in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.15.0
  • Python version used: 3.12
  • Whatever mypy playground currently uses by default

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-runtime-semanticsmypy doesn't model runtime semantics correctly

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions