Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

Activity

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

    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