From 4edee94a815472af01a364849c90c2c292f1a89c Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 17 May 2024 13:32:20 +0200 Subject: [PATCH] Update mypy-dev to 1.11.0a2 (#117630) --- homeassistant/core.py | 14 -------------- homeassistant/helpers/service.py | 2 +- mypy.ini | 1 + requirements_test.txt | 2 +- script/hassfest/mypy_config.py | 5 +++++ 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/homeassistant/core.py b/homeassistant/core.py index 3b3143acf6f..8c08a0198b0 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -580,8 +580,6 @@ class HomeAssistant: functools.partial(self.async_create_task, target, eager_start=True) ) return - if TYPE_CHECKING: - target = cast(Callable[[*_Ts], Any], target) self.loop.call_soon_threadsafe( functools.partial(self._async_add_hass_job, HassJob(target), *args) ) @@ -648,12 +646,6 @@ class HomeAssistant: if asyncio.iscoroutine(target): return self.async_create_task(target, eager_start=eager_start) - # This code path is performance sensitive and uses - # if TYPE_CHECKING to avoid the overhead of constructing - # the type used for the cast. For history see: - # https://github.com/home-assistant/core/pull/71960 - if TYPE_CHECKING: - target = cast(Callable[[*_Ts], Coroutine[Any, Any, _R] | _R], target) return self._async_add_hass_job(HassJob(target), *args) @overload @@ -987,12 +979,6 @@ class HomeAssistant: if asyncio.iscoroutine(target): return self.async_create_task(target, eager_start=True) - # This code path is performance sensitive and uses - # if TYPE_CHECKING to avoid the overhead of constructing - # the type used for the cast. For history see: - # https://github.com/home-assistant/core/pull/71960 - if TYPE_CHECKING: - target = cast(Callable[[*_Ts], Coroutine[Any, Any, _R] | _R], target) return self.async_run_hass_job(HassJob(target), *args) def block_till_done(self, wait_background_tasks: bool = False) -> None: diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index bc6bef3f0ed..1396f37e665 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -1048,7 +1048,7 @@ async def _handle_entity_call( result = await task if asyncio.iscoroutine(result): - _LOGGER.error( + _LOGGER.error( # type: ignore[unreachable] ( "Service %s for %s incorrectly returns a coroutine object. Await result" " instead in service handler. Report bug to integration author" diff --git a/mypy.ini b/mypy.ini index 782f0cd9920..ffd3db822dd 100644 --- a/mypy.ini +++ b/mypy.ini @@ -8,6 +8,7 @@ platform = linux plugins = pydantic.mypy show_error_codes = true follow_imports = normal +enable_incomplete_feature = NewGenericSyntax local_partial_types = true strict_equality = true no_implicit_optional = true diff --git a/requirements_test.txt b/requirements_test.txt index c65d10aece0..610abffc733 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -11,7 +11,7 @@ astroid==3.1.0 coverage==7.5.0 freezegun==1.5.0 mock-open==1.4.0 -mypy==1.10.0 +mypy-dev==1.11.0a2 pre-commit==3.7.1 pydantic==1.10.15 pylint==3.1.1 diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index fab3d5fcd7f..56734257f78 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -36,6 +36,11 @@ GENERAL_SETTINGS: Final[dict[str, str]] = { "plugins": "pydantic.mypy", "show_error_codes": "true", "follow_imports": "normal", + "enable_incomplete_feature": ",".join( # noqa: FLY002 + [ + "NewGenericSyntax", + ] + ), # Enable some checks globally. "local_partial_types": "true", "strict_equality": "true",