Files
ruff/crates
Charlie Marsh 2abaff046e [ty] Narrow on negative subscript indexing (#22682)
## Summary

Negative subscripts are also indicative of a thing being subcriptable:

```python
class Subscriptable:
    def __getitem__(self, key: int) -> int:
        return 42

class NotSubscriptable: ...

def _(x: list[Subscriptable | NotSubscriptable]):
    if not isinstance(x[-1], NotSubscriptable):
        # After narrowing, x[-1] excludes NotSubscriptable, which means subscripting works
        reveal_type(x[-1])  # revealed: Subscriptable & ~NotSubscriptable
        reveal_type(x[-1][0])  # revealed: int
```
2026-01-19 09:04:08 -05:00
..
2026-01-15 12:53:20 -05:00
2026-01-02 19:58:15 +00:00
2026-01-02 19:58:15 +00:00
2026-01-02 19:58:15 +00:00
2026-01-02 19:58:15 +00:00
2026-01-02 19:58:15 +00:00
2026-01-02 19:58:15 +00:00