@@ -2426,7 +2426,7 @@ def check_assignment(self, lvalue: Lvalue, rvalue: Expression, infer_lvalue_type
2426
2426
2427
2427
# Special case: only non-abstract non-protocol classes can be assigned to
2428
2428
# variables with explicit type Type[A], where A is protocol or abstract.
2429
- if not self .check_concrete_only_assign (lvalue_type , rvalue_type , rvalue ):
2429
+ if not self .check_concrete_only_assign (lvalue_type , lvalue , rvalue_type , rvalue ):
2430
2430
return
2431
2431
if rvalue_type and infer_lvalue_type and not isinstance (lvalue_type , PartialType ):
2432
2432
# Don't use type binder for definitions of special forms, like named tuples.
@@ -2444,8 +2444,16 @@ def check_assignment(self, lvalue: Lvalue, rvalue: Expression, infer_lvalue_type
2444
2444
self .infer_variable_type (inferred , lvalue , rvalue_type , rvalue )
2445
2445
self .check_assignment_to_slots (lvalue )
2446
2446
2447
- def check_concrete_only_assign (self , lvalue_type : Optional [Type ],
2448
- rvalue_type : Type , rvalue : Expression ) -> bool :
2447
+ def check_concrete_only_assign (self ,
2448
+ lvalue_type : Optional [Type ],
2449
+ lvalue : Expression ,
2450
+ rvalue_type : Type ,
2451
+ rvalue : Expression ) -> bool :
2452
+ if (isinstance (lvalue , NameExpr ) and isinstance (rvalue , NameExpr )
2453
+ and lvalue .node == rvalue .node ):
2454
+ # This means that we reassign abstract class to itself. Like `A = A`
2455
+ return True
2456
+
2449
2457
rvalue_type = get_proper_type (rvalue_type )
2450
2458
lvalue_type = get_proper_type (lvalue_type )
2451
2459
if not (
0 commit comments