@@ -26,9 +26,7 @@ class C:
2626c_instance = C(1 )
2727
2828reveal_type(c_instance.inferred_from_value) # revealed: Unknown | Literal[1, "a"]
29-
30- # TODO : Same here. This should be `Unknown | Literal[1, "a"]`
31- reveal_type(c_instance.inferred_from_other_attribute) # revealed: Unknown
29+ reveal_type(c_instance.inferred_from_other_attribute) # revealed: Unknown | Literal[1, "a"]
3230
3331# There is no special handling of attributes that are (directly) assigned to a declared parameter,
3432# which means we union with `Unknown` here, since the attribute itself is not declared. This is
@@ -177,8 +175,7 @@ c_instance = C(1)
177175
178176reveal_type(c_instance.inferred_from_value) # revealed: Unknown | Literal[1, "a"]
179177
180- # TODO : Should be `Unknown | Literal[1, "a"]`
181- reveal_type(c_instance.inferred_from_other_attribute) # revealed: Unknown
178+ reveal_type(c_instance.inferred_from_other_attribute) # revealed: Unknown | Literal[1, "a"]
182179
183180reveal_type(c_instance.inferred_from_param) # revealed: Unknown | int | None
184181
@@ -399,9 +396,19 @@ class TupleIterable:
399396
400397class C :
401398 def __init__ (self ) -> None :
399+ # TODO : Should not emit this diagnostic
400+ # error: [unresolved-attribute]
402401 [... for self .a in IntIterable()]
402+ # TODO : Should not emit this diagnostic
403+ # error: [unresolved-attribute]
404+ # error: [unresolved-attribute]
403405 [... for (self .b, self .c) in TupleIterable()]
406+ # TODO : Should not emit this diagnostic
407+ # error: [unresolved-attribute]
408+ # error: [unresolved-attribute]
404409 [... for self .d in IntIterable() for self .e in IntIterable()]
410+ # TODO : Should not emit this diagnostic
411+ # error: [unresolved-attribute]
405412 [[... for self .f in IntIterable()] for _ in IntIterable()]
406413 [[... for self .g in IntIterable()] for self in [D()]]
407414
@@ -598,6 +605,8 @@ class C:
598605 self .c = c
599606 if False :
600607 def set_e (self , e : str ) -> None :
608+ # TODO : Should not emit this diagnostic
609+ # error: [unresolved-attribute]
601610 self .e = e
602611
603612# TODO : this would ideally be `Unknown | Literal[1]`
@@ -685,7 +694,7 @@ class C:
685694 pure_class_variable2: ClassVar = 1
686695
687696 def method (self ):
688- # TODO : this should be an error
697+ # error: [invalid-attribute-access] "Cannot assign to ClassVar `pure_class_variable1` from an instance of type `Self@method`"
689698 self .pure_class_variable1 = " value set through instance"
690699
691700reveal_type(C.pure_class_variable1) # revealed: str
@@ -885,11 +894,9 @@ class Intermediate(Base):
885894 # TODO : This should be an error (violates Liskov)
886895 self .redeclared_in_method_with_wider_type: object = object ()
887896
888- # TODO : This should be an `invalid-assignment` error
889- self .overwritten_in_subclass_method = None
897+ self .overwritten_in_subclass_method = None # error: [invalid-assignment]
890898
891- # TODO : This should be an `invalid-assignment` error
892- self .pure_overwritten_in_subclass_method = None
899+ self .pure_overwritten_in_subclass_method = None # error: [invalid-assignment]
893900
894901 self .pure_undeclared = " intermediate"
895902
@@ -1839,6 +1846,7 @@ def external_getattribute(name) -> int:
18391846
18401847class ThisFails :
18411848 def __init__ (self ):
1849+ # error: [invalid-assignment] "Implicit shadowing of function `__getattribute__`"
18421850 self .__getattribute__ = external_getattribute
18431851
18441852# error: [unresolved-attribute]
0 commit comments