[ty] implement proper handling of recursive types in CycleDetector#24773
Draft
mtshiba wants to merge 2 commits intoastral-sh:mainfrom
Draft
[ty] implement proper handling of recursive types in CycleDetector#24773mtshiba wants to merge 2 commits intoastral-sh:mainfrom
CycleDetector#24773mtshiba wants to merge 2 commits intoastral-sh:mainfrom
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 breakdownsphinx
|
|
| Project | Old Status | New Status | Old Return Code | New Return Code |
|---|---|---|---|---|
more-itertools |
success | timeout | 1 |
None |
Diagnostic changes:
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
4 | 0 | 28 |
invalid-assignment |
0 | 0 | 2 |
type-assertion-failure |
2 | 0 | 0 |
unsupported-operator |
1 | 0 | 1 |
invalid-return-type |
0 | 1 | 0 |
no-matching-overload |
1 | 0 | 0 |
| Total | 8 | 1 | 31 |
Raw diff (40 changes)
artigraph (https://github.com/artigraph/artigraph)
- src/arti/graphs/__init__.py:358:36 error[invalid-argument-type] Argument to bound method `BackendConnection.write_artifact_and_graph_partitions` is incorrect: Expected `Artifact`, found `Artifact | TypedBox[Artifact]`
+ src/arti/graphs/__init__.py:358:36 error[invalid-argument-type] Argument to bound method `BackendConnection.write_artifact_and_graph_partitions` is incorrect: Expected `Artifact`, found `TypedNode[Artifact]`
core (https://github.com/home-assistant/core)
- homeassistant/components/api/__init__.py:286:28 error[invalid-argument-type] Argument to bound method `StateMachine.async_set` is incorrect: Expected `str`, found `dict[str, Any] | list[Any] | str | int | float`
+ homeassistant/components/api/__init__.py:286:28 error[invalid-argument-type] Argument to bound method `StateMachine.async_set` is incorrect: Expected `str`, found `dict[str, JsonValueType] | list[JsonValueType] | str | int | float`
- homeassistant/components/api/__init__.py:286:39 error[invalid-argument-type] Argument to bound method `StateMachine.async_set` is incorrect: Expected `Mapping[str, Any] | None`, found `dict[str, Any] | list[Any] | str | ... omitted 3 union elements`
+ homeassistant/components/api/__init__.py:286:39 error[invalid-argument-type] Argument to bound method `StateMachine.async_set` is incorrect: Expected `Mapping[str, Any] | None`, found `JsonValueType | None`
- homeassistant/components/api/__init__.py:286:51 error[invalid-argument-type] Argument to bound method `StateMachine.async_set` is incorrect: Expected `bool`, found `dict[str, Any] | list[Any] | str | ... omitted 3 union elements`
+ homeassistant/components/api/__init__.py:286:51 error[invalid-argument-type] Argument to bound method `StateMachine.async_set` is incorrect: Expected `bool`, found `JsonValueType`
- homeassistant/components/api/__init__.py:353:44 error[invalid-argument-type] Argument to bound method `State.from_dict` is incorrect: Expected `dict[str, Any]`, found `dict[str, Any] | list[Any] | str | ... omitted 3 union elements`
+ homeassistant/components/api/__init__.py:353:44 error[invalid-argument-type] Argument to bound method `State.from_dict` is incorrect: Expected `dict[str, Any]`, found `dict[str, JsonValueType] | list[JsonValueType] | str | ... omitted 3 union elements`
- homeassistant/components/api/__init__.py:500:37 error[invalid-argument-type] Argument to bound method `Template.async_render` is incorrect: Expected `TemplateVarsType`, found `dict[str, Any] | list[Any] | str | ... omitted 3 union elements`
+ homeassistant/components/api/__init__.py:500:37 error[invalid-argument-type] Argument to bound method `Template.async_render` is incorrect: Expected `TemplateVarsType`, found `JsonValueType | None`
- homeassistant/components/conversation/chat_log.py:472:17 error[invalid-argument-type] Argument is incorrect: Expected `dict[str, dict[str, Any] | list[Any] | str | ... omitted 3 union elements]`, found `Unknown | dict[str, str]`
+ homeassistant/components/conversation/chat_log.py:472:17 error[invalid-argument-type] Argument is incorrect: Expected `JsonObjectType`, found `Unknown | dict[str, str]`
- homeassistant/components/cover/reproduce_state.py:220:9 error[invalid-argument-type] Argument to function `_async_set_position` is incorrect: Expected `partial[Coroutine[Any, Any, ServiceResponse]]`, found `partial[CoroutineType[Any, Any, dict[str, dict[str, Any] | list[Any] | str | ... omitted 3 union elements] | None]]`
+ homeassistant/components/cover/reproduce_state.py:220:9 error[invalid-argument-type] Argument to function `_async_set_position` is incorrect: Expected `partial[Coroutine[Any, Any, ServiceResponse]]`, found `partial[CoroutineType[Any, Any, ServiceResponse]]`
- homeassistant/components/cover/reproduce_state.py:223:9 error[invalid-argument-type] Argument to function `_async_set_tilt_position` is incorrect: Expected `partial[Coroutine[Any, Any, ServiceResponse]]`, found `partial[CoroutineType[Any, Any, dict[str, dict[str, Any] | list[Any] | str | ... omitted 3 union elements] | None]]`
+ homeassistant/components/cover/reproduce_state.py:223:9 error[invalid-argument-type] Argument to function `_async_set_tilt_position` is incorrect: Expected `partial[Coroutine[Any, Any, ServiceResponse]]`, found `partial[CoroutineType[Any, Any, ServiceResponse]]`
- homeassistant/components/cover/reproduce_state.py:228:13 error[invalid-argument-type] Argument to function `_async_close_cover` is incorrect: Expected `partial[Coroutine[Any, Any, ServiceResponse]]`, found `partial[CoroutineType[Any, Any, dict[str, dict[str, Any] | list[Any] | str | ... omitted 3 union elements] | None]]`
+ homeassistant/components/cover/reproduce_state.py:228:13 error[invalid-argument-type] Argument to function `_async_close_cover` is incorrect: Expected `partial[Coroutine[Any, Any, ServiceResponse]]`, found `partial[CoroutineType[Any, Any, ServiceResponse]]`
- homeassistant/components/cover/reproduce_state.py:233:13 error[invalid-argument-type] Argument to function `_async_open_cover` is incorrect: Expected `partial[Coroutine[Any, Any, ServiceResponse]]`, found `partial[CoroutineType[Any, Any, dict[str, dict[str, Any] | list[Any] | str | ... omitted 3 union elements] | None]]`
+ homeassistant/components/cover/reproduce_state.py:233:13 error[invalid-argument-type] Argument to function `_async_open_cover` is incorrect: Expected `partial[Coroutine[Any, Any, ServiceResponse]]`, found `partial[CoroutineType[Any, Any, ServiceResponse]]`
- homeassistant/components/google_assistant/http.py:413:12 error[invalid-return-type] Return type does not match returned value: expected `list[str]`, found `list[object]`
- homeassistant/components/mqtt/cover.py:441:23 error[invalid-assignment] Object of type `dict[str, Any] | list[Any] | str | ... omitted 3 union elements` is not assignable to `ReceivePayloadType`
+ homeassistant/components/mqtt/cover.py:441:23 error[invalid-assignment] Object of type `dict[str, JsonValueType] | list[JsonValueType] | str | ... omitted 3 union elements` is not assignable to `ReceivePayloadType`
- homeassistant/components/websocket_api/connection.py:205:21 error[invalid-argument-type] Argument to function `error_message` is incorrect: Expected `int | None`, found `dict[str, Any] | list[Any] | str | ... omitted 3 union elements`
+ homeassistant/components/websocket_api/connection.py:205:21 error[invalid-argument-type] Argument to function `error_message` is incorrect: Expected `int | None`, found `dict[str, JsonValueType] | list[JsonValueType] | str | ... omitted 3 union elements`
- homeassistant/helpers/restore_state.py:284:37 error[invalid-argument-type] Argument to bound method `State.from_dict` is incorrect: Expected `dict[str, Any]`, found `dict[str, Any] | list[Any] | str | ... omitted 3 union elements`
+ homeassistant/helpers/restore_state.py:284:37 error[invalid-argument-type] Argument to bound method `State.from_dict` is incorrect: Expected `dict[str, Any]`, found `JsonValueType`
- homeassistant/helpers/singleton.py:103:5 error[invalid-argument-type] Argument is incorrect: Expected `(HomeAssistant, /) -> Coroutine[Any, Any, int]`, found `def func_error(hass: HomeAssistant) -> int`
+ homeassistant/helpers/singleton.py:103:5 error[invalid-argument-type] Argument is incorrect: Expected `_FuncType[_Coro[int]]`, found `def func_error(hass: HomeAssistant) -> int`
+ homeassistant/helpers/storage.py:461:35 error[invalid-argument-type] Argument to bound method `Store.async_save` is incorrect: Argument type `Unknown | dict[str, JsonValueType] | list[JsonValueType] | ... omitted 4 union elements` does not satisfy upper bound `Mapping[str, Any] | Sequence[Any]` of type variable `_T`
+ homeassistant/helpers/storage.py:461:35 error[invalid-argument-type] Argument to bound method `Store.async_save` is incorrect: Expected `_T@Store`, found `Unknown | dict[str, JsonValueType] | list[JsonValueType] | ... omitted 4 union elements`
- homeassistant/helpers/storage.py:429:12 error[unsupported-operator] Operator `not in` is not supported between objects of type `Literal["minor_version"]` and `dict[str, Any] | list[Any] | str | ... omitted 3 union elements`
+ homeassistant/helpers/storage.py:429:12 error[unsupported-operator] Operator `not in` is not supported between objects of type `Literal["minor_version"]` and `dict[str, Any] | dict[str, JsonValueType] | list[JsonValueType] | ... omitted 4 union elements`
- homeassistant/helpers/storage.py:430: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[Any]`
+ homeassistant/helpers/storage.py:430: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:433:13 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["version"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:433:13 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:434:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["minor_version"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:434:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:436:22 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["data"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:436:22 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:438:16 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["version"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:438:16 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:438:16 error[unsupported-operator] Operator `>` is not supported between objects of type `Any | dict[str, JsonValueType] | list[JsonValueType] | ... omitted 4 union elements` and `int`
- homeassistant/helpers/storage.py:440:31 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["version"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:440:31 error[invalid-argument-type] Argument to `UnsupportedStorageVersionError.__init__` is incorrect: Expected `int`, found `Any | dict[str, JsonValueType] | list[JsonValueType] | ... omitted 4 union elements`
+ homeassistant/helpers/storage.py:440:31 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:445:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["version"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:445:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:446:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["minor_version"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:446:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:451:57 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["version"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:451:57 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:451:74 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["data"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:451:74 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:455:25 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["version"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:455:25 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:455:42 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["minor_version"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:455:42 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:455:65 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["data"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:455:65 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:24 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["version"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:458:24 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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:460:30 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Any, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[Any]]` cannot be called with key of type `Literal["data"]` on object of type `list[Any]`
+ homeassistant/helpers/storage.py:460:30 error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> JsonValueType, (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]`
more-itertools (https://github.com/more-itertools/more-itertools)
- FAILED old=success(1) new=timeout(None)
scipy-stubs (https://github.com/scipy/scipy-stubs)
+ tests/integrate/test_solve_bvp.pyi:19:18 error[invalid-argument-type] Argument to function `solve_bvp` is incorrect: Expected `(Array1D, Unknown, /) -> Unknown`, found `def fun0(x: ndarray[tuple[Any, ...], dtype[float64]], y: ndarray[tuple[Any, ...], dtype[float64]]) -> ndarray[tuple[Any, ...], dtype[float64]]`
+ tests/integrate/test_solve_bvp.pyi:20:1 error[type-assertion-failure] Type `Unknown` does not match asserted type `PPoly[float64]`
+ tests/integrate/test_solve_bvp.pyi:30:8 error[no-matching-overload] No overload of function `solve_bvp` matches arguments
+ tests/integrate/test_solve_bvp.pyi:31:1 error[type-assertion-failure] Type `Unknown` does not match asserted type `PPoly[float64]`
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
This fixes the known issues with handling recursive aliases, as described here and elsewhere.
This allows us to safely remove the
MAX_RECURSION_DEPTHlimit that was associated withCycleDetector.The point is that in the previous implementation, we simply compared types using hash values to guard against recursion, but this was insufficient. By manually adding equality checks, the depth limit is no longer necessary.
Test Plan
mdtest updated