[ty] Use invalid-assignment error code for invalid assignments to ClassVars (#20156)

## Summary

This error is about assigning to attributes rather than reading
attributes, so I think `invalid-assignment` makes more sense than
`invalid-attribute-access`

## Test Plan

existing mdtests updated
This commit is contained in:
Alex Waygood 2025-08-29 18:43:30 +01:00 committed by GitHub
parent fa7798ddd9
commit 9b1b58a451
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 15 additions and 15 deletions

View file

@ -1387,7 +1387,7 @@ class ClassVarXProto(Protocol):
def f(obj: ClassVarXProto):
reveal_type(obj.x) # revealed: int
reveal_type(type(obj).x) # revealed: int
obj.x = 42 # error: [invalid-attribute-access] "Cannot assign to ClassVar `x` from an instance of type `ClassVarXProto`"
obj.x = 42 # error: [invalid-assignment] "Cannot assign to ClassVar `x` from an instance of type `ClassVarXProto`"
class InstanceAttrX:
x: int