Commit Graph
11 Commits
Author SHA1 Message Date
Amethyst Reese 09db380143 Apply ruff formatting to mdtests (#22935)
- Updated the `prek` hook to replace `blacken-docs` with ruff
- Added some formatting directives to preserve obvious intentional
formatting choices
- Made some choice edits to content for better readability with new format
- Formatted md tests and updated snapshots
2026-02-13 08:48:14 -08:00
Charlie MarshandDavid Peter b142e7b455 [ty] Use try-call-dunder pattern for __class_getitem__ (#23066)
## Summary

I think `__class_getitem__` is a bit different than (e.g.)
`__contains__` because it's called on the class itself, not instances...
So given `Identity[0]` where `Identity` is a class, using
`try_call_dunder` would call `member_lookup_with_policy` with
`NO_INSTANCE_FALLBACK`, which would look at the metaclass, but not
`Identity` itself.

I added `try_call_dunder_on_class` for consistency which calls `member`
(without `NO_INSTANCE_FALLBACK`), though as far as this PR is concerned,
I think our current behavior was ok?

Closes https://github.com/astral-sh/ty/issues/190.

---------

Co-authored-by: David Peter <mail@david-peter.de>
2026-02-04 10:10:10 +01:00
Charlie Marsh ceabccb9a7 [ty] Add support for subscripts on intersections (#22654)
## Summary

Closes https://github.com/astral-sh/ty/issues/2072.
2026-01-24 14:59:35 +00:00
Alex Waygood 5a18e93d65 [ty] Make special cases for subscript inference exhaustive (#22035)
## Summary

Fixes https://github.com/astral-sh/ty/issues/2015. We weren't recursing
into the value of a type alias when we should have been.

There are situations where we should also be recursing into the
bounds/constraints of a typevar. I initially tried to do that as well in
this PR, but that seems... trickier. For now I'm cutting scope; this PR
does, however, add several failing tests for those cases.

## Test Plan

added mdtests
2026-01-15 00:18:54 +00:00
Simon Lamon c032e27566 [ty] Rename non-subscriptable error code to not-subscriptable (#22193) 2025-12-27 11:44:35 +00:00
David Peter bbfcf6e111 [ty] __class_getitem__ is a classmethod (#20192)
## Summary

`__class_getitem__` is [implicitly a
classmethod](https://docs.python.org/3/reference/datamodel.html#object.__class_getitem__).

## Test Plan

Added regression test.
2025-09-01 11:22:19 +02:00
Alex Waygood e44c489273 [ty] Fix false positives when subscripting an object inferred as having an Intersection type (#18920) 2025-06-24 18:39:02 +00:00
Suneet TipirneniandCarl Meyer ef8281b695 [ty] add support for mapped union and intersection subscript loads (#18846)
## Summary

Note this modifies the diagnostics a bit. Previously performing
subscript access on something like `NotSubscriptable1 |
NotSubscriptable2` would report the full type as not being
subscriptable:

```
[non-subscriptable] "Cannot subscript object of type `NotSubscriptable1 | NotSubscriptable2` with no `__getitem__` method"
```

Now each erroneous constituent has a separate error:

```
[non-subscriptable] "Cannot subscript object of type `NotSubscriptable2` with no `__getitem__` method"
[non-subscriptable] "Cannot subscript object of type `NotSubscriptable1` with no `__getitem__` method"
```

Closes https://github.com/astral-sh/ty/issues/625

## Test Plan

 mdtest

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
2025-06-23 16:38:01 +00:00
InSync bcefa459f4 [ty] Rename call-possibly-unbound-method to possibly-unbound-implicit-call (#18017) 2025-05-22 15:25:51 +00:00
Charlie Marsh a2e9a7732a Update class literal display to use <class 'Foo'> style (#17889)
## Summary

Closes https://github.com/astral-sh/ruff/issues/17238.
2025-05-06 20:11:25 -04:00
Micha Reiser b51c4f82ea Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00