[ty] Preserve recursive class TypeVar defaults through cycles#24455
Closed
charliermarsh wants to merge 3 commits intomainfrom
Closed
[ty] Preserve recursive class TypeVar defaults through cycles#24455charliermarsh wants to merge 3 commits intomainfrom
charliermarsh wants to merge 3 commits intomainfrom
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 87.72%. The percentage of expected errors that received a diagnostic held steady at 82.85%. The number of fully passing files held steady at 74/132. |
dba2109 to
9c03835
Compare
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
flake8
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-await |
0 | 40 | 0 |
unresolved-attribute |
0 | 0 | 22 |
invalid-argument-type |
17 | 0 | 3 |
invalid-assignment |
1 | 0 | 2 |
unsupported-operator |
1 | 0 | 1 |
invalid-return-type |
0 | 1 | 0 |
| Total | 19 | 41 | 28 |
Changes in flaky projects detected. Raw diff output excludes flaky projects; see the HTML report for details.
Raw diff (47 changes)
boostedblob (https://github.com/hauntsaninja/boostedblob)
- boostedblob/listing.py:402:14 error[unresolved-attribute] Object of type `Element[Unknown]` has no attribute `iterchildren`
+ boostedblob/listing.py:402:14 error[unresolved-attribute] Object of type `Element[str]` has no attribute `iterchildren`
cloud-init (https://github.com/canonical/cloud-init)
- cloudinit/sources/helpers/azure.py:518:32 error[unresolved-attribute] Attribute `text` is not defined on `None` in union `Element[Unknown] | None`
+ cloudinit/sources/helpers/azure.py:518:32 error[unresolved-attribute] Attribute `text` is not defined on `None` in union `Element[str] | None`
core (https://github.com/home-assistant/core)
+ homeassistant/helpers/storage.py:464:35 error[invalid-argument-type] Argument to bound method `async_save` is incorrect: Argument type `Unknown | dict[str, Any] | list[Any] | ... omitted 4 union elements` does not satisfy upper bound `Mapping[str, Any] | Sequence[Any]` of type variable `_T`
+ homeassistant/helpers/storage.py:464:35 error[invalid-argument-type] Argument to bound method `async_save` is incorrect: Expected `_T@Store`, found `Unknown | dict[str, Any] | list[Any] | ... omitted 4 union elements`
- homeassistant/helpers/storage.py:432:12 error[unsupported-operator] Operator `not in` is not supported between objects of type `Literal["minor_version"]` and `dict[str, Any] | Unknown | list[Any] | ... omitted 4 union elements`
+ homeassistant/helpers/storage.py:432:12 error[unsupported-operator] Operator `not in` is not supported between objects of type `Literal["minor_version"]` and `dict[str, Any] | Unknown | dict[str, JsonValueType] | ... omitted 6 union elements`
+ homeassistant/helpers/storage.py:433:13 error[invalid-assignment] Invalid subscript assignment with key of type `Literal["minor_version"]` and value of type `Literal[1]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:436:13 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:437:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["minor_version"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:439:22 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["data"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:441:16 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:441:16 error[unsupported-operator] Operator `>` is not supported between objects of type `Any | dict[str, Any] | list[Any] | ... omitted 4 union elements` and `Unknown | int`
+ homeassistant/helpers/storage.py:443:31 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `int`, found `Any | dict[str, Any] | list[Any] | ... omitted 4 union elements`
+ homeassistant/helpers/storage.py:443:31 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:448:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:449:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["minor_version"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:454:57 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:454:74 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["data"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:458:25 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:458:42 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["minor_version"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:458:65 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["data"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:461:24 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["version"]` on object of type `list[JsonValueType]`
+ homeassistant/helpers/storage.py:463:30 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> dict[str, Any] | list[JsonValueType] | str | ... omitted 3 union elements, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[JsonValueType]]` cannot be called with key of type `Literal["data"]` on object of type `list[JsonValueType]`
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- tests/contrib/pytest/test_pytest_atr.py:337:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_atr.py:337:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_atr.py:338:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_atr.py:338:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_atr.py:339:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_atr.py:339:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_atr.py:340:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_atr.py:340:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_attempt_to_fix.py:259:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_attempt_to_fix.py:259:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_attempt_to_fix.py:260:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_attempt_to_fix.py:260:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_attempt_to_fix.py:261:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_attempt_to_fix.py:261:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_attempt_to_fix.py:262:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_attempt_to_fix.py:262:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_attempt_to_fix.py:271:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_attempt_to_fix.py:271:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_attempt_to_fix.py:272:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_attempt_to_fix.py:272:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_attempt_to_fix.py:273:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_attempt_to_fix.py:273:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_attempt_to_fix.py:274:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_attempt_to_fix.py:274:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_efd.py:515:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_efd.py:515:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
- tests/contrib/pytest/test_pytest_efd.py:516:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[Unknown] | None`
+ tests/contrib/pytest/test_pytest_efd.py:516:16 error[unresolved-attribute] Attribute `attrib` is not defined on `None` in union `Element[str] | None`
meson (https://github.com/mesonbuild/meson)
- mesonbuild/mtest.py:1122:17 error[invalid-assignment] Object of type `ElementTree[Element[Unknown]]` is not assignable to attribute `junit` of type `ElementTree[Element[Unknown] | None] | None`
+ mesonbuild/mtest.py:1122:17 error[invalid-assignment] Object of type `ElementTree[Element[str]]` is not assignable to attribute `junit` of type `ElementTree[Element[str] | None] | None`
- run_project_tests.py:1283:42 error[invalid-argument-type] Argument to function `SubElement` is incorrect: Expected `Element[Any]`, found `Element[Unknown] | None`
+ run_project_tests.py:1283:42 error[invalid-argument-type] Argument to function `SubElement` is incorrect: Expected `Element[Any]`, found `Element[str] | None`
- run_project_tests.py:1299:42 error[invalid-argument-type] Argument to function `SubElement` is incorrect: Expected `Element[Any]`, found `Element[Unknown] | None`
+ run_project_tests.py:1299:42 error[invalid-argument-type] Argument to function `SubElement` is incorrect: Expected `Element[Any]`, found `Element[str] | None`
- run_project_tests.py:1358:13 error[invalid-argument-type] Argument to function `SubElement` is incorrect: Expected `Element[Any]`, found `Element[Unknown] | None`
+ run_project_tests.py:1358:13 error[invalid-argument-type] Argument to function `SubElement` is incorrect: Expected `Element[Any]`, found `Element[str] | None`
pandas (https://github.com/pandas-dev/pandas)
- pandas/io/xml.py:483:21 error[unresolved-attribute] Attribute `findall` is not defined on `None` in union `Element[Unknown] | Unknown | None`
+ pandas/io/xml.py:483:21 error[unresolved-attribute] Attribute `findall` is not defined on `None` in union `Element[str] | Unknown | None`
- pandas/io/xml.py:516:26 error[unresolved-attribute] Attribute `find` is not defined on `None` in union `Element[Unknown] | Unknown | None`
+ pandas/io/xml.py:516:26 error[unresolved-attribute] Attribute `find` is not defined on `None` in union `Element[str] | Unknown | None`
- pandas/io/xml.py:600:17 error[unresolved-attribute] Attribute `xpath` is not defined on `Element[Unknown]`, `None` in union `Element[Unknown] | Unknown | None`
+ pandas/io/xml.py:600:17 error[unresolved-attribute] Attribute `xpath` is not defined on `Element[str]`, `None` in union `Element[str] | Unknown | None`
- pandas/io/xml.py:626:28 error[unresolved-attribute] Attribute `xpath` is not defined on `Element[Unknown]`, `None` in union `Element[Unknown] | Unknown | None`
+ pandas/io/xml.py:626:28 error[unresolved-attribute] Attribute `xpath` is not defined on `Element[str]`, `None` in union `Element[str] | Unknown | None`
pytest (https://github.com/pytest-dev/pytest)
- src/_pytest/junitxml.py:258:9 error[invalid-assignment] Object of type `() -> Element[Unknown]` is not assignable to attribute `to_xml` of type `def to_xml(self) -> Element[Unknown]`
+ src/_pytest/junitxml.py:258:9 error[invalid-assignment] Object of type `() -> Element[str]` is not assignable to attribute `to_xml` of type `def to_xml(self) -> Element[str]`
spack (https://github.com/spack/spack)
- lib/spack/spack/test/conftest.py:1912:16 error[unresolved-attribute] Attribute `get` is not defined on `None` in union `Element[Unknown] | None`
+ lib/spack/spack/test/conftest.py:1912:16 error[unresolved-attribute] Attribute `get` is not defined on `None` in union `Element[str] | None`
zulip (https://github.com/zulip/zulip)
- zerver/lib/markdown/nested_code_blocks.py:51:21 error[unresolved-attribute] Attribute `tag` is not defined on `None` in union `Element[Unknown] | None`
+ zerver/lib/markdown/nested_code_blocks.py:51:21 error[unresolved-attribute] Attribute `tag` is not defined on `None` in union `Element[str] | None`bdc2681 to
11c31ec
Compare
11c31ec to
6c805e5
Compare
MeGaGiGaGon
reviewed
Apr 8, 2026
|
|
||
| reveal_type(Recursive()) # revealed: Recursive[Recursive[Unknown]] | ||
| reveal_type(Nested()) # revealed: Nested[list[Nested[Unknown]]] | ||
| reveal_type(RecursivePartial()) # revealed: RecursivePartial[int, RecursivePartial[Unknown, Unknown]] |
Contributor
There was a problem hiding this comment.
Theoretically this could be RecursivePartial[int, RecursivePartial[int, Unknown]], since only the implicit U is recursively looping.
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
Closes astral-sh/ty#3229.