From 3894d39c0c98ec4de1bbf83d832e6fa9dbd11747 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:10:30 +0000 Subject: [PATCH 1/3] Force import of Async/Generator from collections.abc --- pylint/plugins/hass_imports.py | 12 ++++++++++++ tests/components/twitch/__init__.py | 3 +-- tests/components/youtube/__init__.py | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pylint/plugins/hass_imports.py b/pylint/plugins/hass_imports.py index 3ec8b6c3cd921d..c6f6683754d1db 100644 --- a/pylint/plugins/hass_imports.py +++ b/pylint/plugins/hass_imports.py @@ -398,6 +398,18 @@ class ObsoleteImportMatch: constant=re.compile(r"^save_json|find_paths_unserializable_data$"), ), ], + "typing": [ + ObsoleteImportMatch( + reason="should be imported from collections.abc", + constant=re.compile(r"^(Async)?Generator$"), + ), + ], + "typing_extensions": [ + ObsoleteImportMatch( + reason="should be imported from collections.abc", + constant=re.compile(r"^(Async)?Generator$"), + ), + ], } diff --git a/tests/components/twitch/__init__.py b/tests/components/twitch/__init__.py index 0238bbdadbafed..2d70aaf96495a5 100644 --- a/tests/components/twitch/__init__.py +++ b/tests/components/twitch/__init__.py @@ -1,10 +1,9 @@ """Tests for the Twitch component.""" -from collections.abc import AsyncIterator +from collections.abc import AsyncGenerator, AsyncIterator from typing import Any, Generic, TypeVar from twitchAPI.object.base import TwitchObject -from typing_extensions import AsyncGenerator from homeassistant.components.twitch import DOMAIN from homeassistant.core import HomeAssistant diff --git a/tests/components/youtube/__init__.py b/tests/components/youtube/__init__.py index 1b559f0f1c4619..31125d3a71e643 100644 --- a/tests/components/youtube/__init__.py +++ b/tests/components/youtube/__init__.py @@ -1,8 +1,8 @@ """Tests for the YouTube integration.""" +from collections.abc import AsyncGenerator import json -from typing_extensions import AsyncGenerator from youtubeaio.models import YouTubeChannel, YouTubePlaylistItem, YouTubeSubscription from youtubeaio.types import AuthScope From 4700c19d5c47789951a1cecf767ca5fec55bdd47 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:16:08 +0000 Subject: [PATCH 2/3] Adjust --- pylint/plugins/hass_imports.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pylint/plugins/hass_imports.py b/pylint/plugins/hass_imports.py index c6f6683754d1db..ff088e7bce1242 100644 --- a/pylint/plugins/hass_imports.py +++ b/pylint/plugins/hass_imports.py @@ -398,12 +398,6 @@ class ObsoleteImportMatch: constant=re.compile(r"^save_json|find_paths_unserializable_data$"), ), ], - "typing": [ - ObsoleteImportMatch( - reason="should be imported from collections.abc", - constant=re.compile(r"^(Async)?Generator$"), - ), - ], "typing_extensions": [ ObsoleteImportMatch( reason="should be imported from collections.abc", From 390d0975bf4962fd2b1b527c3aaae78710fc58f0 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:47:50 +0200 Subject: [PATCH 3/3] Don't force --- pylint/plugins/hass_imports.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pylint/plugins/hass_imports.py b/pylint/plugins/hass_imports.py index ff088e7bce1242..3ec8b6c3cd921d 100644 --- a/pylint/plugins/hass_imports.py +++ b/pylint/plugins/hass_imports.py @@ -398,12 +398,6 @@ class ObsoleteImportMatch: constant=re.compile(r"^save_json|find_paths_unserializable_data$"), ), ], - "typing_extensions": [ - ObsoleteImportMatch( - reason="should be imported from collections.abc", - constant=re.compile(r"^(Async)?Generator$"), - ), - ], }