[ty] fix goto definition for generic classes#24714
Merged
dcreager merged 9 commits intoastral-sh:mainfrom Apr 21, 2026
Merged
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 87.94%. The percentage of expected errors that received a diagnostic held steady at 83.36%. The number of fully passing files held steady at 79/133. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
trio
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
9 | 0 | 0 |
invalid-assignment |
9 | 0 | 0 |
unused-type-ignore-comment |
0 | 8 | 0 |
invalid-return-type |
4 | 0 | 0 |
no-matching-overload |
4 | 0 | 0 |
unknown-argument |
2 | 0 | 0 |
unresolved-attribute |
1 | 1 | 0 |
call-non-callable |
1 | 0 | 0 |
not-subscriptable |
1 | 0 | 0 |
| Total | 31 | 9 | 0 |
Raw diff (40 changes)
anyio (https://github.com/agronholm/anyio)
+ src/anyio/_core/_tempfile.py:423:22 error[no-matching-overload] No overload of bound method `AsyncFile.write` matches arguments
+ src/anyio/_core/_tempfile.py:451:22 error[no-matching-overload] No overload of bound method `AsyncFile.writelines` matches arguments
beartype (https://github.com/beartype/beartype)
- beartype/typing/_typingpep544.py:520:31 error[unresolved-attribute] Object of type `<super: <class 'Protocol'>, type[Self@__class_getitem__]>` has no attribute `__class_getitem__`
+ beartype/typing/_typingpep544.py:568:25 error[call-non-callable] Object of type `object` is not callable
+ beartype/typing/_typingpep544.py:585:9 error[invalid-assignment] Object of type `type[Self@__class_getitem__]` is not assignable to attribute `__origin__` on type `Unknown | type[Self@__class_getitem__]`
bokeh (https://github.com/bokeh/bokeh)
+ src/bokeh/core/property/container.py:136:37 error[invalid-argument-type] Argument to `Seq.__init__` is incorrect: Expected `list[Never] | UndefinedType | IntrinsicType`, found `list[list[Never]] | UndefinedType | IntrinsicType`
core (https://github.com/home-assistant/core)
+ homeassistant/components/ring/binary_sensor.py:162:9 error[invalid-assignment] Cannot assign to a subscript on an object of type `Mapping[str, Any]`
+ homeassistant/components/ring/binary_sensor.py:166:9 error[invalid-assignment] Cannot assign to a subscript on an object of type `Mapping[str, Any]`
discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/context.py:1120:16 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- discord/ext/commands/hybrid.py:349:52 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- discord/ui/select.py:494:32 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- discord/ui/select.py:676:32 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- discord/ui/select.py:776:32 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- discord/ui/select.py:888:32 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- discord/ui/select.py:1009:32 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/funcs.py:102:41 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
ibis (https://github.com/ibis-project/ibis)
+ ibis/expr/operations/generic.py:148:26 error[unknown-argument] Argument `value` does not match any known parameter
+ ibis/expr/operations/generic.py:148:39 error[unknown-argument] Argument `dtype` does not match any known parameter
prefect (https://github.com/PrefectHQ/prefect)
+ src/integrations/prefect-ray/prefect_ray/task_runners.py:314:28 error[invalid-argument-type] Argument to bound method `TaskRunner.map` is incorrect: Expected `Task[P@map, R@RayTaskRunner | CoroutineType[Any, Any, R@RayTaskRunner]]`, found `Task[P@map, R@RayTaskRunner]`
+ src/prefect/input/run_input.py:448:16 error[unresolved-attribute] Attribute `value` is not defined on `Coroutine[Any, Any, Self@load]` in union `Self@load | Coroutine[Any, Any, Self@load]`
werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/datastructures/mixins.py:260:14 error[no-matching-overload] No overload of bound method `MutableMapping.setdefault` matches arguments
+ src/werkzeug/datastructures/mixins.py:309:13 error[invalid-argument-type] Argument to bound method `MutableMapping.update` is incorrect: Expected `SupportsGetItem[str, V@UpdateDictMixin]`, found `Self@update`
+ src/werkzeug/datastructures/structures.py:238:20 error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `V@MultiDict`
+ src/werkzeug/datastructures/structures.py:239:24 error[not-subscriptable] Cannot subscript object of type `V@MultiDict` with no `__getitem__` method
+ src/werkzeug/datastructures/structures.py:248:34 error[invalid-argument-type] Argument to bound method `dict.__setitem__` is incorrect: Expected `V@MultiDict`, found `list[V@MultiDict]`
+ src/werkzeug/datastructures/structures.py:258:9 error[no-matching-overload] No overload of bound method `MutableMapping.setdefault` matches arguments
+ src/werkzeug/datastructures/structures.py:281:27 error[invalid-assignment] Object of type `V@MultiDict` is not assignable to `list[V@MultiDict]`
+ src/werkzeug/datastructures/structures.py:310:34 error[invalid-argument-type] Argument to bound method `dict.__setitem__` is incorrect: Expected `V@MultiDict`, found `list[V@MultiDict]`
+ src/werkzeug/datastructures/structures.py:349:38 error[invalid-argument-type] Argument to bound method `dict.__setitem__` is incorrect: Expected `V@MultiDict`, found `list[Unknown]`
+ src/werkzeug/datastructures/structures.py:351:16 error[invalid-return-type] Return type does not match returned value: expected `list[V@MultiDict]`, found `V@MultiDict`
+ src/werkzeug/datastructures/structures.py:362:18 error[invalid-assignment] Object of type `V@MultiDict` is not assignable to `list[V@MultiDict]`
+ src/werkzeug/datastructures/structures.py:374:18 error[invalid-assignment] Object of type `V@MultiDict` is not assignable to `list[V@MultiDict]`
+ src/werkzeug/datastructures/structures.py:381:13 error[invalid-assignment] Object of type `V@MultiDict` is not assignable to `list[V@MultiDict]`
+ src/werkzeug/datastructures/structures.py:392:16 error[invalid-return-type] Return type does not match returned value: expected `Iterable[list[V@MultiDict]]`, found `dict_values[K@MultiDict, V@MultiDict]`
+ src/werkzeug/datastructures/structures.py:498:19 error[invalid-assignment] Object of type `V@MultiDict` is not assignable to `list[V@MultiDict]`
+ src/werkzeug/datastructures/structures.py:515:20 error[invalid-assignment] Object of type `tuple[K@MultiDict, V@MultiDict]` is not assignable to `tuple[K@MultiDict, list[V@MultiDict]]`
+ src/werkzeug/datastructures/structures.py:532:16 error[invalid-return-type] Return type does not match returned value: expected `list[V@MultiDict]`, found `V@MultiDict | list[Unknown]`
+ src/werkzeug/datastructures/structures.py:537:20 error[invalid-return-type] Return type does not match returned value: expected `tuple[K@MultiDict, list[V@MultiDict]]`, found `tuple[K@MultiDict, V@MultiDict]`
xarray (https://github.com/pydata/xarray)
+ xarray/core/resample.py:59:13 error[invalid-argument-type] Argument to bound method `DataArray.rename` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `DataArray` of type variable `Self`
+ xarray/core/resample.py:59:13 error[invalid-argument-type] Argument to bound method `Dataset.rename` is incorrect: Argument type `T_Xarray@Resample` does not satisfy upper bound `Dataset` of type variable `Self`
dcreager
reviewed
Apr 21, 2026
| reveal_type(super()) # revealed: <super: <class 'MyProtocol'>, type[Self@__class_getitem__]> | ||
| parent_method = super().__class_getitem__ | ||
| reveal_type(parent_method) # revealed: @Todo(super in generic class) | ||
| parent_method = super().__class_getitem__ # error: [unresolved-attribute] "Object of type `<super: <class 'MyProtocol'>, type[Self@__class_getitem__]>` has no attribute `__class_getitem__`" |
Member
There was a problem hiding this comment.
The strawberry ecosystem changes are related to this. I think this new expectation is not correct; __class_getitem__ should be resolvable. I'm taking a quick look to see if there's an easy fix.
Member
There was a problem hiding this comment.
Latest patches remove the ecosystem changes for strawberry
ed067d4 to
e08bed1
Compare
Member
|
ecosystem: The bokeh change looks like a new true positive. All of the others look like existing false positives that are exposed in new places, but that aren't in scope for this PR. |
dcreager
approved these changes
Apr 21, 2026
Contributor
Author
|
Thank you for the review and fixing the |
This was referenced Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, this fixes astral-sh/ty#2854
Summary
Compare class literals instead of class bases for the purposes of skipping the MRO until the pivot class.
Also skip
BoundSuperTypewhen looking up definitions since we probably do not want to look up definitions on thesuperclass itself.Test Plan
Added snapshot tests