mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-02 21:03:11 +00:00
## Summary
Adds validation to subscript assignment expressions.
```py
class Foo: ...
class Bar:
__setattr__ = None
class Baz:
def __setitem__(self, index: str, value: int) -> None:
pass
# We now emit a diagnostic on these statements
Foo()[1] = 2
Bar()[1] = 2
Baz()[1] = 2
```
Also improves error messages on invalid `__getitem__` expressions
## Test Plan
Update mdtests and add more to `subscript/instance.md`
---------
Co-authored-by: David Peter <sharkdp@users.noreply.github.com>
Co-authored-by: David Peter <mail@david-peter.de>
|
||
|---|---|---|
| .. | ||
| conditionals | ||
| assert.md | ||
| assignment.md | ||
| bool-call.md | ||
| boolean.md | ||
| complex_target.md | ||
| hasattr.md | ||
| isinstance.md | ||
| issubclass.md | ||
| match.md | ||
| post_if_statement.md | ||
| truthiness.md | ||
| type.md | ||
| type_guards.md | ||
| while.md | ||