[ty] Ignore generic specialization in layout compatibility checks#25178
Merged
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 89.36%. The percentage of expected errors that received a diagnostic held steady at 85.49%. The number of fully passing files held steady at 88/134. |
Memory usage reportMemory usage unchanged ✅ |
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
2 | 0 | 0 |
instance-layout-conflict |
0 | 1 | 0 |
unresolved-attribute |
0 | 0 | 1 |
| Total | 2 | 1 | 1 |
Raw diff:
beartype (https://github.com/beartype/beartype)
- beartype/claw/_ast/_kind/clawastimport.py:698:40 error[unresolved-attribute] Attribute `get` is not defined on `None` in union `None | (Iota & BeartypeDecorPlaceTrieABC) | (Unknown & BeartypeDecorPlaceTrieABC)`
+ beartype/claw/_ast/_kind/clawastimport.py:698:40 error[unresolved-attribute] Attribute `get` is not defined on `None` in union `None | (dict[str, dict[str, Divergent] | None] & BeartypeDecorPlaceTrieABC) | (Iota & BeartypeDecorPlaceTrieABC) | (Unknown & BeartypeDecorPlaceTrieABC)`
core (https://github.com/home-assistant/core)
+ homeassistant/core.py:633:43 error[invalid-argument-type] Argument to bound method `HomeAssistant.async_create_task` is incorrect: Expected `Coroutine[Any, Any, _R@async_add_job]`, found `(((...) -> Coroutine[Any, Any, _R@async_add_job] | _R@async_add_job) & Coroutine[object, Never, object]) | Coroutine[Any, Any, _R@async_add_job]`
+ homeassistant/core.py:960:43 error[invalid-argument-type] Argument to bound method `HomeAssistant.async_create_task` is incorrect: Expected `Coroutine[Any, Any, _R@async_run_job]`, found `(((...) -> Coroutine[Any, Any, _R@async_run_job] | _R@async_run_job) & Coroutine[object, Never, object]) | Coroutine[Any, Any, _R@async_run_job]`
pyodide (https://github.com/pyodide/pyodide)
- src/py/pyodide/webloop.py:169:7 error[instance-layout-conflict] Class will raise `TypeError` at runtime due to incompatible bases: Bases `Task` and `PyodideFuture` cannot be combined in multiple inheritance
dcreager
approved these changes
May 18, 2026
thejchap
pushed a commit
to thejchap/ruff
that referenced
this pull request
May 23, 2026
…tral-sh#25178) ## Summary Every time someone tries to touch this code, it gets rejected, so I don't have high hopes here. Anyway... Previously, a generic disjoint base and a subclass of that base could be marked as incompatible if the type arguments didn't line up. But at runtime, CPython's instance layout check isn't affected by type arguments. A concrete example is: ```python import asyncio class Future(asyncio.Future): ... class Task(asyncio.Task): ... class SubClass(Task, Future): ... ``` `asyncio.Task` is a subclass of `asyncio.Future`, so these bases can coexist in the same MRO. But before, we ended up doing a comparison like `Task[Unknown] <: Future[Unknown]`, which I believe ends up failing because `Unknown <: Unknown` is false under subtyping?
anishgirianish
pushed a commit
to anishgirianish/ruff
that referenced
this pull request
May 28, 2026
…tral-sh#25178) ## Summary Every time someone tries to touch this code, it gets rejected, so I don't have high hopes here. Anyway... Previously, a generic disjoint base and a subclass of that base could be marked as incompatible if the type arguments didn't line up. But at runtime, CPython's instance layout check isn't affected by type arguments. A concrete example is: ```python import asyncio class Future(asyncio.Future): ... class Task(asyncio.Task): ... class SubClass(Task, Future): ... ``` `asyncio.Task` is a subclass of `asyncio.Future`, so these bases can coexist in the same MRO. But before, we ended up doing a comparison like `Task[Unknown] <: Future[Unknown]`, which I believe ends up failing because `Unknown <: Unknown` is false under subtyping?
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.
Summary
Every time someone tries to touch this code, it gets rejected, so I don't have high hopes here. Anyway...
Previously, a generic disjoint base and a subclass of that base could be marked as incompatible if the type arguments didn't line up. But at runtime, CPython's instance layout check isn't affected by type arguments. A concrete example is:
asyncio.Taskis a subclass ofasyncio.Future, so these bases can coexist in the same MRO. But before, we ended up doing a comparison likeTask[Unknown] <: Future[Unknown], which I believe ends up failing becauseUnknown <: Unknownis false under subtyping?Closes astral-sh/ty#3466.