Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AI0867 opened this issue Feb 6, 2025 · 0 comments · Fixed by #18620
Closed

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

AI0867 opened this issue Feb 6, 2025 · 0 comments · Fixed by #18620
Labels
bug mypy got something wrong topic-runtime-semantics mypy doesn't model runtime semantics correctly

Comments

@AI0867
Copy link

AI0867 commented Feb 6, 2025

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
@AI0867 AI0867 added the bug mypy got something wrong label Feb 6, 2025
@sterliakov sterliakov added the topic-runtime-semantics mypy doesn't model runtime semantics correctly label Feb 6, 2025
JelleZijlstra pushed a commit that referenced this issue Feb 8, 2025
x612skm pushed a commit to x612skm/mypy-dev that referenced this issue Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-runtime-semantics mypy doesn't model runtime semantics correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants