- 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
## 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>
## 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
## 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>