Skip to content
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

type of variable not narrowed after continue statement inside try/except block inside a for loop inside a function #18466

Open
DetachHead opened this issue Jan 14, 2025 · 0 comments
Labels
bug mypy got something wrong topic-type-narrowing Conditional type narrowing / binder

Comments

@DetachHead
Copy link
Contributor

def _() -> None:
    for value in [1,2]:
        try:
            foo = 1
        except Exception:
            foo = None
            continue
        reveal_type(foo) # `int | None`, should be `int`

playground

@DetachHead DetachHead added the bug mypy got something wrong label Jan 14, 2025
@hauntsaninja hauntsaninja added the topic-type-narrowing Conditional type narrowing / binder label Jan 14, 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-type-narrowing Conditional type narrowing / binder
Projects
None yet
Development

No branches or pull requests

2 participants