-
Notifications
You must be signed in to change notification settings - Fork 216
Closed as duplicate of#2158
Labels
typing semanticstyping-module features, spec compliance, etctyping-module features, spec compliance, etc
Milestone
Description
Summary
This is for red knot, tested in https://playknot.ruff.rs/
from typing import ClassVar, assert_type, reveal_type
class B:
x: ClassVar[int | str] = 0
class C(B):
x = "random"
class D(C):
x = 1
class E(D):
x = b"x"
def foo(b: type[B]) -> None:
x = b.x
reveal_type(x)
if isinstance(x, str):
print(x + "y")
else:
reveal_type(x)
print(x + 3)
foo(E)This program crashes with a TypeError because an invalid type is assigned to x in E.
But that invalid assignment is not reported.
Version
https://playknot.ruff.rs/
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
typing semanticstyping-module features, spec compliance, etctyping-module features, spec compliance, etc