fix Unpacked TypeVarTuple in callable doesn't consider optional arguments #1269#4212
Open
asukaminato0721 wants to merge 1 commit into
Open
fix Unpacked TypeVarTuple in callable doesn't consider optional arguments #1269#4212asukaminato0721 wants to merge 1 commit into
asukaminato0721 wants to merge 1 commit into
Conversation
|
Diff from mypy_primer, showing the effect of this PR on open source code: starlette (https://github.com/encode/starlette)
- ERROR tests/test_applications.py:101:26-75: Unpacked argument `tuple[Literal[1013]]` is not assignable to parameter `*args` with type `tuple[int, str | None]` in function `anyio.from_thread.run` [bad-argument-type]
aiohttp (https://github.com/aio-libs/aiohttp)
- ERROR aiohttp/web_request.py:757:63-759:26: Overload type was not compatible with solved type variables: _Ts = tuple[()] [incompatible-overload-residual]
+ ERROR aiohttp/web_request.py:763:43-52: Object of class `FunctionType` has no attribute `write` [missing-attribute]
+ ERROR aiohttp/web_request.py:767:76-85: Object of class `FunctionType` has no attribute `close` [missing-attribute]
+ ERROR aiohttp/web_request.py:769:64-72: Object of class `FunctionType` has no attribute `seek` [missing-attribute]
anyio (https://github.com/agronholm/anyio)
- ERROR src/anyio/_core/_fileio.py:777:40-779:10: Unpacked argument `tuple[str | None, str | None]` is not assignable to parameter `*args` with type `tuple[str | None, str | None, str | None]` in function `anyio.to_thread.run_sync` [bad-argument-type]
- ERROR src/anyio/streams/file.py:78:40-63: Overload type was not compatible with solved type variables: PosArgsT = tuple[str] [incompatible-overload-residual]
- ERROR src/anyio/streams/file.py:148:40-63: Overload type was not compatible with solved type variables: PosArgsT = tuple[str] [incompatible-overload-residual]
- ERROR src/anyio/streams/tls.py:254:49-83: Unpacked argument `tuple[int]` is not assignable to parameter `*args` with type `tuple[int, Buffer | None]` in function `TLSStream._call_sslobject_method` [bad-argument-type]
bandersnatch (https://github.com/pypa/bandersnatch)
- ERROR src/bandersnatch/mirror.py:1118:50-1120:10: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[str, str | None, str | None, str | None]` in function `asyncio.events.AbstractEventLoop.run_in_executor` [bad-argument-type]
core (https://github.com/home-assistant/core)
- ERROR homeassistant/components/aemet/__init__.py:70:38-73:6: Overload type was not compatible with solved type variables: _Ts = tuple[str] [incompatible-overload-residual]
- ERROR homeassistant/components/backup/http.py:141:59-88: Overload type was not compatible with solved type variables: _Ts = tuple[str, str] [incompatible-overload-residual]
- ERROR homeassistant/components/backup/manager.py:1592:60-89: Overload type was not compatible with solved type variables: _Ts = tuple[str, str] [incompatible-overload-residual]
- ERROR homeassistant/components/backup/manager.py:1846:53-79: Overload type was not compatible with solved type variables: _Ts = tuple[str] [incompatible-overload-residual]
- ERROR homeassistant/components/backup/manager.py:1974:41-63: Overload type was not compatible with solved type variables: _Ts = tuple[str] [incompatible-overload-residual]
- ERROR homeassistant/components/backup/manager.py:1998:41-80: Unpacked argument `tuple[Path, Path]` is not assignable to parameter `*args` with type `tuple[StrPath, @_, _CopyFn]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/backup/manager.py:2003:45-71: Overload type was not compatible with solved type variables: _Ts = tuple[str] [incompatible-overload-residual]
- ERROR homeassistant/components/backup/manager.py:2065:45-62: Overload type was not compatible with solved type variables: _Ts = tuple[str] [incompatible-overload-residual]
- ERROR homeassistant/components/device_tracker/legacy.py:1035:52-81: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[str, Unknown]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/freebox/router.py:61:42-69: Unpacked argument `tuple[Unknown]` is not assignable to parameter `*args` with type `tuple[StrOrBytesPath, int, bool]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/frontend/__init__.py:485:46-75: Overload type was not compatible with solved type variables: _Ts = tuple[Path] [incompatible-overload-residual]
- ERROR homeassistant/components/go2rtc/__init__.py:261:45-69: Overload type was not compatible with solved type variables: _Ts = tuple[str] [incompatible-overload-residual]
- ERROR homeassistant/components/google_assistant/http.py:408:55-82: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[PathLike[str] | str, JsonValueType]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/homematic/__init__.py:386:28-394:6: Unpacked argument `tuple[HomeAssistant, Literal['homematic'], Literal['set_install_mode'], (service: ServiceCall) -> None, Schema]` is not assignable to parameter `*args` with type `tuple[HomeAssistant, str, str, (ServiceCall) -> Coroutine[Any, Any, dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None] | dict[str, dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None] | None] | None] | dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None] | dict[str, dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None] | None] | None, VolSchemaType, SupportsResponse]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type]
- ERROR homeassistant/components/html5/notify.py:245:46-247:14: Unpacked argument `tuple[str, dict[str, Registration]]` is not assignable to parameter `*args` with type `tuple[str, dict[Unknown, Unknown] | list[Unknown], bool]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/html5/notify.py:297:46-299:14: Unpacked argument `tuple[str, dict[str, Registration]]` is not assignable to parameter `*args` with type `tuple[str, dict[Unknown, Unknown] | list[Unknown], bool]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/html5/notify.py:573:59-575:22: Unpacked argument `tuple[str, dict[str, Registration]]` is not assignable to parameter `*args` with type `tuple[str, dict[Unknown, Unknown] | list[Unknown], bool]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/html5/notify.py:699:59-701:22: Unpacked argument `tuple[str, dict[str, Registration]]` is not assignable to parameter `*args` with type `tuple[str, dict[Unknown, Unknown] | list[Unknown], bool]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/http/ban.py:220:59-222:14: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[str, Unknown]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/icloud/account.py:227:26-76: Unpacked argument `tuple[HomeAssistant]` is not assignable to parameter `*args` with type `tuple[HomeAssistant, ConfigFlowContext | None, dict[str, Any] | None]` in function `homeassistant.core.HomeAssistant.add_job` [bad-argument-type]
- ERROR homeassistant/components/icloud/config_flow.py:206:51-81: Unpacked argument `tuple[Unknown]` is not assignable to parameter `*args` with type `tuple[StrOrBytesPath, int, bool]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/image_upload/__init__.py:153:47-88: Overload type was not compatible with solved type variables: _Ts = tuple[Path] [incompatible-overload-residual]
- ERROR homeassistant/components/influxdb/__init__.py:549:51-88: Unpacked argument `tuple[dict[str, Any | Unknown], Literal[True]]` is not assignable to parameter `*args` with type `tuple[Unknown, bool | Unknown, bool | Unknown]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/ios/__init__.py:254:51-256:6: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[PathLike[str] | str, dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None]]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/matrix/__init__.py:394:58-396:14: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[PathLike[str] | str, dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None]]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/mjpeg/config_flow.py:117:63-123:14: Unpacked argument `tuple[Any, Any | None, Any, Any]` is not assignable to parameter `*args` with type `tuple[str, str | None, str, bool, str]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/nanoleaf/config_flow.py:144:69-146:10: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[PathLike[str] | str, dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None]]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/nanoleaf/config_flow.py:225:55-227:18: Unpacked argument `tuple[str, dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None]]` is not assignable to parameter `*args` with type `tuple[str, dict[Unknown, Unknown] | list[Unknown], bool]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/notify/legacy.py:270:63-272:10: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[PathLike[str] | str, Unknown]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/picotts/__init__.py:17:41-68: Overload type was not compatible with solved type variables: _Ts = tuple[str] [incompatible-overload-residual]
- ERROR homeassistant/components/picotts/config_flow.py:26:50-77: Overload type was not compatible with solved type variables: _Ts = tuple[str] [incompatible-overload-residual]
- ERROR homeassistant/components/picotts/tts.py:43:41-68: Overload type was not compatible with solved type variables: _Ts = tuple[str] [incompatible-overload-residual]
- ERROR homeassistant/components/tellduslive/config_flow.py:150:54-152:10: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[PathLike[str] | str, dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None]]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/tts/legacy.py:104:54-106:6: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[PathLike[str] | str, Unknown]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/velbus/__init__.py:130:38-133:6: Overload type was not compatible with solved type variables: _Ts = tuple[str] [incompatible-overload-residual]
- ERROR homeassistant/components/velbus/__init__.py:188:46-73: Overload type was not compatible with solved type variables: _Ts = tuple[str] [incompatible-overload-residual]
- ERROR homeassistant/components/vicare/__init__.py:165:63-88: Unpacked argument `tuple[ConfigEntryAuth]` is not assignable to parameter `*args` with type `tuple[ConfigEntryAuth, int]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/components/wmspro/__init__.py:102:42-69: Overload type was not compatible with solved type variables: _Ts = tuple[Path] [incompatible-overload-residual]
- ERROR homeassistant/core.py:1562:45-1564:10: Unpacked argument `tuple[EventType[_DataT] | str, _DataT | None, EventOrigin, Context | None]` is not assignable to parameter `*args` with type `tuple[EventType[@_] | str, @_ | None, EventOrigin, Context | None, float | None]` in function `asyncio.events.AbstractEventLoop.call_soon_threadsafe` [bad-argument-type]
- ERROR homeassistant/core.py:1692:56-1694:10: Unpacked argument `tuple[EventType[_DataT] | str, (Event[_DataT]) -> Coroutine[Any, Any, None] | None]` is not assignable to parameter `*args` with type `tuple[EventType[@_] | str, (Event[@_]) -> Coroutine[Any, Any, None] | None, ((@_) -> bool) | None, bool | object]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type]
- ERROR homeassistant/core.py:1769:56-1771:10: Unpacked argument `tuple[EventType[_DataT] | str, (Event[_DataT]) -> Coroutine[Any, Any, None] | None]` is not assignable to parameter `*args` with type `tuple[EventType[@_] | str, (Event[@_]) -> Coroutine[Any, Any, None] | None, bool | object]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type]
- ERROR homeassistant/core.py:2306:39-2308:10: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[str, Context | None]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type]
- ERROR homeassistant/core.py:2353:32-2361:10: Unpacked argument `tuple[str, str, Mapping[str, Any] | None, bool, Context | None]` is not assignable to parameter `*args` with type `tuple[str, str, Mapping[str, Any] | None, bool, Context | None, StateInfo | None, float | None]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type]
- ERROR homeassistant/core.py:2702:32-2710:10: Unpacked argument `tuple[str, str, (ServiceCall) -> Coroutine[Any, Any, ServiceResponse] | dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None] | None, Schema | None, SupportsResponse]` is not assignable to parameter `*args` with type `tuple[str, str, (ServiceCall) -> Coroutine[Any, Any, dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None] | dict[str, dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None] | None] | None] | dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None] | dict[str, dict[str, bool | dict[str, JsonValueType] | float | int | list[JsonValueType] | str | None] | None] | None, All | Any | Schema | None, SupportsResponse, HassJobType | None, Mapping[str, str] | None]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type]
- ERROR homeassistant/helpers/condition.py:1509:35-1518:6: Unpacked argument `tuple[HomeAssistant, State | str | None, float | str | None, float | str | None, Template | None, TemplateVarsType]` is not assignable to parameter `*args` with type `tuple[HomeAssistant, State | str | None, float | str | None, float | str | None, Template | None, TemplateVarsType, str | None]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type]
- ERROR homeassistant/helpers/condition.py:1806:35-1808:6: Unpacked argument `tuple[HomeAssistant, Template, TemplateVarsType]` is not assignable to parameter `*args` with type `tuple[HomeAssistant, Template, TemplateVarsType, bool]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type]
- ERROR homeassistant/helpers/storage.py:366:62-368:18: Unpacked argument `tuple[Unknown]` is not assignable to parameter `*args` with type `tuple[PathLike[str] | str, JsonValueType]` in function `homeassistant.core.HomeAssistant.async_add_executor_job` [bad-argument-type]
- ERROR homeassistant/helpers/template/__init__.py:559:39-564:10: Unpacked argument `tuple[Unknown, object | Unknown]` is not assignable to parameter `*args` with type `tuple[Any, Any, dict[str, Any] | None, bool]` in function `homeassistant.util.async_.run_callback_threadsafe` [bad-argument-type]
trio (https://github.com/python-trio/trio)
- ERROR src/trio/_core/_asyncgens.py:175:41-78: Unpacked argument `tuple[Task | None]` is not assignable to parameter `*args` with type `tuple[Task, Outcome[object]]` in function `trio._core._entry_queue.EntryQueue.run_sync_soon` [bad-argument-type]
+ ERROR src/trio/_core/_asyncgens.py:175:41-78: Unpacked argument `tuple[Task | None]` is not assignable to parameter `*args` with type `tuple[*tuple[Task] | tuple[Task, Outcome[object]]]` in function `trio._core._entry_queue.EntryQueue.run_sync_soon` [bad-argument-type]
- ERROR src/trio/_core/_tests/type_tests/nursery_start.py:71:23-43: Unpacked argument `tuple[Literal['abc'], Literal[12]]` is not assignable to parameter `*args` with type `tuple[str, int, bool]` in function `trio._core._run.Nursery.start_soon` [bad-argument-type]
- ERROR src/trio/_repl.py:134:38-64: Unpacked argument `tuple[str]` is not assignable to parameter `*args` with type `tuple[str | None, str | None]` in function `trio._threads.to_thread_run_sync` [bad-argument-type]
- ERROR src/trio/_ssl.py:721:45-79: Unpacked argument `tuple[int]` is not assignable to parameter `*args` with type `tuple[int, Buffer | None]` in function `SSLStream._retry` [bad-argument-type]
kopf (https://github.com/nolar/kopf)
- ERROR kopf/_cogs/clients/api.py:40:38-86: Unpacked argument `tuple[tuple[str, int]]` is not assignable to parameter `*args` with type `tuple[tuple[str, int], int, str | None, float]` in function `asyncio.events.AbstractEventLoop.run_in_executor` [bad-argument-type]
|
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
Fixes #1269
Callable inference now models every valid positional prefix introduced by optional parameters, allowing later *args evidence to select the correct Ts arity
Test Plan
add test