mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:16 +00:00
[ty] Use invalid-assignment
error code for invalid assignments to ClassVar
s (#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:
parent
fa7798ddd9
commit
9b1b58a451
6 changed files with 15 additions and 15 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue