ruff/crates/ty_python_semantic/resources/mdtest
Matthew Mckee b30d97e5e0
[ty] Support __setitem__ and improve __getitem__ related diagnostics (#19578)
## 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>
2025-08-01 09:23:27 +02:00
..
annotations [ty] Fallback to Unknown if no type is stored for an expression (#19517) 2025-07-25 02:05:32 +00:00
assignment [ty] Remove special casing for tuple addition (#19636) 2025-07-30 16:25:42 +00:00
binary [ty] Remove special casing for string-literal-in-tuple __contains__ (#19642) 2025-07-31 11:28:03 +01:00
boolean Revert "[ty] Better control flow for boolean expressions that are inside if (#18010)" (#18150) 2025-05-17 08:27:32 -04:00
boundness_declaredness
call [ty] Support async/await, async with and yield from (#19595) 2025-07-30 11:51:21 +02:00
class
comparison [ty] Enum literal types (#19328) 2025-07-15 21:31:53 +02:00
comprehensions [ty] Async for loops and async iterables (#19634) 2025-07-30 17:40:24 +02:00
conditional [ty] Exhaustiveness checking & reachability for match statements (#19508) 2025-07-23 22:45:45 +02:00
dataclasses [ty] Add basic support for dataclasses.field (#19553) 2025-07-25 14:56:04 +02:00
declaration [ty] Format conflicting types as an enumeration (#18956) 2025-06-26 14:29:33 +02:00
diagnostics [ty] Async for loops and async iterables (#19634) 2025-07-30 17:40:24 +02:00
directives [ty] Exhaustiveness checking & reachability for match statements (#19508) 2025-07-23 22:45:45 +02:00
doc
exception [ty] support del statement and deletion of except handler names (#18593) 2025-06-12 07:44:42 -07:00
expression [ty] Support async/await, async with and yield from (#19595) 2025-07-30 11:51:21 +02:00
function [ty] Minor: test isolation (#19597) 2025-07-28 15:52:59 +02:00
generics [ty] Upcast heterogeneous and mixed tuples to homogeneous tuples where it's necessary to solve a TypeVar (#19635) 2025-07-30 17:12:21 +01:00
ide_support [ty] Remove special casing for string-literal-in-tuple __contains__ (#19642) 2025-07-31 11:28:03 +01:00
import lint on the global keyword if there's no explicit definition in the global scope 2025-07-15 16:56:54 -07:00
literal
loops [ty] Async for loops and async iterables (#19634) 2025-07-30 17:40:24 +02:00
narrow [ty] Support __setitem__ and improve __getitem__ related diagnostics (#19578) 2025-08-01 09:23:27 +02:00
regression
scopes [ty] improve lazy scope place lookup (#19321) 2025-07-25 07:11:11 +00:00
shadowing
snapshots [ty] Remove special casing for string-literal-in-tuple __contains__ (#19642) 2025-07-31 11:28:03 +01:00
stubs [ty] Do not carry the generic context of Protocol or Generic in the ClassBase enum (#17989) 2025-05-22 21:37:03 -04:00
subscript [ty] Support __setitem__ and improve __getitem__ related diagnostics (#19578) 2025-08-01 09:23:27 +02:00
suppressions [ty] Consistent use of American english (in rules) (#19488) 2025-07-22 16:10:38 +02:00
type_compendium [ty] Make tuple subclass constructors sound (#19469) 2025-07-21 21:25:11 +00:00
type_of [ty] Improve the Display for generic type[] types (#19667) 2025-07-31 19:45:01 +01:00
type_properties [ty] Infer single-valuedness for enums based on int/str (#19510) 2025-07-23 15:55:42 +02:00
type_qualifiers [ty] Support dataclasses.InitVar (#19527) 2025-07-24 16:33:33 +02:00
unary
with [ty] Support async/await, async with and yield from (#19595) 2025-07-30 11:51:21 +02:00
.mdformat.toml
async.md [ty] Support async/await, async with and yield from (#19595) 2025-07-30 11:51:21 +02:00
attributes.md [ty] Attribute access on intersections with negative parts (#19524) 2025-07-25 14:56:14 +02:00
cycle.md
decorators.md
del.md [ty] Support __setitem__ and improve __getitem__ related diagnostics (#19578) 2025-08-01 09:23:27 +02:00
deprecated.md [ty] Consistent use of American english (in rules) (#19488) 2025-07-22 16:10:38 +02:00
descriptor_protocol.md [ty] Fix descriptor lookups for most types that overlap with None (#19120) 2025-07-05 19:34:23 +01:00
enums.md [ty] Exhaustiveness checking & reachability for match statements (#19508) 2025-07-23 22:45:45 +02:00
exhaustiveness_checking.md [ty] Exhaustiveness checking & reachability for match statements (#19508) 2025-07-23 22:45:45 +02:00
final.md
instance_layout_conflict.md [ty] Remove special casing for tuple addition (#19636) 2025-07-30 16:25:42 +00:00
intersection_types.md [ty] Expansion of enums into unions of literals (#19382) 2025-07-21 19:37:55 +02:00
invalid_syntax.md
known_constants.md
mdtest_config.md
mdtest_custom_typeshed.md
metaclass.md
mro.md [ty] Implement implicit inheritance from Generic[] for PEP-695 generic classes (#18283) 2025-05-26 20:40:16 +01:00
named_tuple.md [ty] Add generic inference for dataclasses (#18443) 2025-06-03 09:59:43 -07:00
overloads.md [ty] Add support for @staticmethods (#18809) 2025-06-20 10:38:17 +02:00
pep695_type_aliases.md [ty] Support typing.TypeAliasType (#18156) 2025-05-19 16:36:49 +02:00
properties.md
protocols.md [ty] Attribute access on intersections with negative parts (#19524) 2025-07-25 14:56:14 +02:00
public_types.md [ty] improve lazy scope place lookup (#19321) 2025-07-25 07:11:11 +00:00
statically_known_branches.md [ty] Infer nonlocal types as unions of all reachable bindings (#18750) 2025-06-26 12:24:40 +02:00
sys_platform.md
sys_version_info.md
terminal_statements.md [ty] improve lazy scope place lookup (#19321) 2025-07-25 07:11:11 +00:00
ty_extensions.md [ty] Rename type_api => ty_extensions (#19523) 2025-07-24 08:24:26 +00:00
typed_dict.md [ty] Reduce false positives for TypedDict types (#19354) 2025-07-15 12:47:19 +01:00
union_types.md [ty] Expansion of enums into unions of literals (#19382) 2025-07-21 19:37:55 +02:00
unpacking.md [ty] Support variable-length tuples in unpacking assignments (#18948) 2025-06-27 15:29:04 -04:00
unreachable.md [ty] improve lazy scope place lookup (#19321) 2025-07-25 07:11:11 +00:00