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

(🎁) Intersections with @final types should trigger unreachable errors #15148

Closed
KotlinIsland opened this issue Apr 26, 2023 · 2 comments · Fixed by #16330
Closed

(🎁) Intersections with @final types should trigger unreachable errors #15148

KotlinIsland opened this issue Apr 26, 2023 · 2 comments · Fixed by #16330
Labels
feature topic-final PEP 591 topic-reachability Detecting unreachable code

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Apr 26, 2023

from typing import final

@final
class A: ...
class B: ...

a: A
assert isinstance(a, B)
reveal_type(a)  # note: Revealed type is "__main__.<subclass of "A" and "B">"
print("hi") # no unreachable error
@NeilGirdhar
Copy link
Contributor

NeilGirdhar commented May 1, 2023

"Intersections with @final types should trigger unreachable errors"… (unless A already inherits from B of course 😄)

@tyralla
Copy link
Contributor

tyralla commented Oct 27, 2023

@KotlinIsland: #16330 should fix this issue. Would you like to review it?

hauntsaninja pushed a commit that referenced this issue Dec 4, 2023
…16330)

Fixes #15148

I think it also fixes the [initial
bug](#12163 (comment))
reported in #12163 (this is why I added a TypeVar test case) but not
[this
bug](#12163 (comment))
reported later in the same issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature topic-final PEP 591 topic-reachability Detecting unreachable code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants