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

no error when using generic in except block #17248

Open
DetachHead opened this issue May 15, 2024 · 0 comments
Open

no error when using generic in except block #17248

DetachHead opened this issue May 15, 2024 · 0 comments
Labels
bug mypy got something wrong topic-runtime-semantics mypy doesn't model runtime semantics correctly

Comments

@DetachHead
Copy link
Contributor

from typing import Generic, TypeVar

T = TypeVar("T")


class Foo(Exception, Generic[T]): ...


try:
    raise Foo
except Foo[int]: # no error, crashes at runtime
    ...

playground

this should be a type error because it fails at runtime with the following exception:

TypeError: catching classes that do not inherit from BaseException is not allowed
@DetachHead DetachHead added the bug mypy got something wrong label May 15, 2024
@hauntsaninja hauntsaninja added the topic-runtime-semantics mypy doesn't model runtime semantics correctly label May 20, 2024
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

No branches or pull requests

2 participants