[ty] Subscript assignment diagnostics follow-up (#21452)

## Summary

Follow up from https://github.com/astral-sh/ruff/pull/21411. Again,
there are more things that could be improved here (like the diagnostics
for `lists`, or extending what we have for `dict` to `OrderedDict` etc),
but that will have to be postponed.
This commit is contained in:
David Peter
2025-11-17 12:14:58 +01:00
committed by GitHub
parent 901e9cdf49
commit 1a86e13472
11 changed files with 110 additions and 32 deletions

View File

@@ -110,6 +110,6 @@ class Identity:
pass
a = Identity()
# error: [invalid-assignment] "Method `__setitem__` of type `bound method Identity.__setitem__(index: int, value: int) -> None` cannot be called with a key of type `Literal["a"]` and a value of type `Literal[0]` on object of type `Identity`"
# error: [invalid-assignment] "Invalid subscript assignment with key of type `Literal["a"]` and value of type `Literal[0]` on object of type `Identity`"
a["a"] = 0
```