From 391b2f8ccd67d3e99ac24bfa0af36de2d0532540 Mon Sep 17 00:00:00 2001 From: Ruslan Sayfutdinov Date: Thu, 20 May 2021 16:53:29 +0100 Subject: [PATCH] Add missing return type in Core constructors (#50884) --- homeassistant/auth/__init__.py | 2 +- homeassistant/config_entries.py | 2 +- homeassistant/core.py | 2 +- homeassistant/data_entry_flow.py | 4 +++- homeassistant/helpers/collection.py | 10 ++++++---- homeassistant/helpers/config_entry_oauth2_flow.py | 4 ++-- homeassistant/helpers/debounce.py | 2 +- homeassistant/helpers/entity_component.py | 2 +- homeassistant/helpers/entity_platform.py | 2 +- homeassistant/helpers/entity_registry.py | 2 +- homeassistant/helpers/event.py | 4 ++-- homeassistant/helpers/ratelimit.py | 2 +- homeassistant/helpers/script_variables.py | 2 +- homeassistant/helpers/service.py | 2 +- homeassistant/helpers/storage.py | 2 +- homeassistant/helpers/template.py | 2 +- homeassistant/helpers/trace.py | 2 +- homeassistant/helpers/update_coordinator.py | 2 +- homeassistant/loader.py | 2 +- homeassistant/util/yaml/loader.py | 2 +- 20 files changed, 29 insertions(+), 25 deletions(-) diff --git a/homeassistant/auth/__init__.py b/homeassistant/auth/__init__.py index 14981d0df09..931c2f4c11a 100644 --- a/homeassistant/auth/__init__.py +++ b/homeassistant/auth/__init__.py @@ -79,7 +79,7 @@ async def auth_manager_from_config( class AuthManagerFlowManager(data_entry_flow.FlowManager): """Manage authentication flows.""" - def __init__(self, hass: HomeAssistant, auth_manager: AuthManager): + def __init__(self, hass: HomeAssistant, auth_manager: AuthManager) -> None: """Init auth manager flows.""" super().__init__(hass) self.auth_manager = auth_manager diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index c586fcad79f..729d8ae94fa 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -569,7 +569,7 @@ class ConfigEntriesFlowManager(data_entry_flow.FlowManager): def __init__( self, hass: HomeAssistant, config_entries: ConfigEntries, hass_config: dict - ): + ) -> None: """Initialize the config entry flow manager.""" super().__init__(hass) self.config_entries = config_entries diff --git a/homeassistant/core.py b/homeassistant/core.py index b1610faad6e..5447277e835 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -163,7 +163,7 @@ class HassJob: __slots__ = ("job_type", "target") - def __init__(self, target: Callable): + def __init__(self, target: Callable) -> None: """Create a job object.""" if asyncio.iscoroutine(target): raise ValueError("Coroutine not allowed to be passed to HassJob") diff --git a/homeassistant/data_entry_flow.py b/homeassistant/data_entry_flow.py index dd8b1c53a68..786cfe7e286 100644 --- a/homeassistant/data_entry_flow.py +++ b/homeassistant/data_entry_flow.py @@ -44,7 +44,9 @@ class UnknownStep(FlowError): class AbortFlow(FlowError): """Exception to indicate a flow needs to be aborted.""" - def __init__(self, reason: str, description_placeholders: dict | None = None): + def __init__( + self, reason: str, description_placeholders: dict | None = None + ) -> None: """Initialize an abort flow exception.""" super().__init__(f"Flow aborted: {reason}") self.reason = reason diff --git a/homeassistant/helpers/collection.py b/homeassistant/helpers/collection.py index bfffb8523dd..6d9815e54d5 100644 --- a/homeassistant/helpers/collection.py +++ b/homeassistant/helpers/collection.py @@ -66,7 +66,7 @@ class CollectionError(HomeAssistantError): class ItemNotFound(CollectionError): """Raised when an item is not found.""" - def __init__(self, item_id: str): + def __init__(self, item_id: str) -> None: """Initialize item not found error.""" super().__init__(f"Item {item_id} not found.") self.item_id = item_id @@ -103,7 +103,9 @@ class IDManager: class ObservableCollection(ABC): """Base collection type that can be observed.""" - def __init__(self, logger: logging.Logger, id_manager: IDManager | None = None): + def __init__( + self, logger: logging.Logger, id_manager: IDManager | None = None + ) -> None: """Initialize the base collection.""" self.logger = logger self.id_manager = id_manager or IDManager() @@ -190,7 +192,7 @@ class StorageCollection(ObservableCollection): store: Store, logger: logging.Logger, id_manager: IDManager | None = None, - ): + ) -> None: """Initialize the storage collection.""" super().__init__(logger, id_manager) self.store = store @@ -389,7 +391,7 @@ class StorageCollectionWebsocket: model_name: str, create_schema: dict, update_schema: dict, - ): + ) -> None: """Initialize a websocket CRUD.""" self.storage_collection = storage_collection self.api_prefix = api_prefix diff --git a/homeassistant/helpers/config_entry_oauth2_flow.py b/homeassistant/helpers/config_entry_oauth2_flow.py index 514c31f355b..8704932db73 100644 --- a/homeassistant/helpers/config_entry_oauth2_flow.py +++ b/homeassistant/helpers/config_entry_oauth2_flow.py @@ -107,7 +107,7 @@ class LocalOAuth2Implementation(AbstractOAuth2Implementation): client_secret: str, authorize_url: str, token_url: str, - ): + ) -> None: """Initialize local auth implementation.""" self.hass = hass self._domain = domain @@ -437,7 +437,7 @@ class OAuth2Session: hass: HomeAssistant, config_entry: config_entries.ConfigEntry, implementation: AbstractOAuth2Implementation, - ): + ) -> None: """Initialize an OAuth2 session.""" self.hass = hass self.config_entry = config_entry diff --git a/homeassistant/helpers/debounce.py b/homeassistant/helpers/debounce.py index 8e7e57fa142..75e0215d2cb 100644 --- a/homeassistant/helpers/debounce.py +++ b/homeassistant/helpers/debounce.py @@ -20,7 +20,7 @@ class Debouncer: cooldown: float, immediate: bool, function: Callable[..., Awaitable[Any]] | None = None, - ): + ) -> None: """Initialize debounce. immediate: indicate if the function needs to be called right away and diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index f1623889946..37c0a7620ab 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -76,7 +76,7 @@ class EntityComponent: domain: str, hass: HomeAssistant, scan_interval: timedelta = DEFAULT_SCAN_INTERVAL, - ): + ) -> None: """Initialize an entity component.""" self.logger = logger self.hass = hass diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index 3331c71dd32..26bfdb43e66 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -85,7 +85,7 @@ class EntityPlatform: platform: ModuleType | None, scan_interval: timedelta, entity_namespace: str | None, - ): + ) -> None: """Initialize the entity platform.""" self.hass = hass self.logger = logger diff --git a/homeassistant/helpers/entity_registry.py b/homeassistant/helpers/entity_registry.py index 5d3ede31ee6..af0c5f4f20f 100644 --- a/homeassistant/helpers/entity_registry.py +++ b/homeassistant/helpers/entity_registry.py @@ -146,7 +146,7 @@ class RegistryEntry: class EntityRegistry: """Class to hold a registry of entities.""" - def __init__(self, hass: HomeAssistant): + def __init__(self, hass: HomeAssistant) -> None: """Initialize the registry.""" self.hass = hass self.entities: dict[str, RegistryEntry] diff --git a/homeassistant/helpers/event.py b/homeassistant/helpers/event.py index cdcacb8871b..48dd05d2311 100644 --- a/homeassistant/helpers/event.py +++ b/homeassistant/helpers/event.py @@ -534,7 +534,7 @@ class _TrackStateChangeFiltered: hass: HomeAssistant, track_states: TrackStates, action: Callable[[Event], Any], - ): + ) -> None: """Handle removal / refresh of tracker init.""" self.hass = hass self._action = action @@ -775,7 +775,7 @@ class _TrackTemplateResultInfo: hass: HomeAssistant, track_templates: Iterable[TrackTemplate], action: Callable, - ): + ) -> None: """Handle removal / refresh of tracker init.""" self.hass = hass self._job = HassJob(action) diff --git a/homeassistant/helpers/ratelimit.py b/homeassistant/helpers/ratelimit.py index c34cfb72b36..389b3f4d2d5 100644 --- a/homeassistant/helpers/ratelimit.py +++ b/homeassistant/helpers/ratelimit.py @@ -19,7 +19,7 @@ class KeyedRateLimit: def __init__( self, hass: HomeAssistant, - ): + ) -> None: """Initialize ratelimit tracker.""" self.hass = hass self._last_triggered: dict[Hashable, datetime] = {} diff --git a/homeassistant/helpers/script_variables.py b/homeassistant/helpers/script_variables.py index a72d0b5543f..23241f22d1e 100644 --- a/homeassistant/helpers/script_variables.py +++ b/homeassistant/helpers/script_variables.py @@ -12,7 +12,7 @@ from . import template class ScriptVariables: """Class to hold and render script variables.""" - def __init__(self, variables: dict[str, Any]): + def __init__(self, variables: dict[str, Any]) -> None: """Initialize script variables.""" self.variables = variables self._has_template: bool | None = None diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index ed23926b0a3..31befb36531 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -73,7 +73,7 @@ class ServiceParams(TypedDict): class ServiceTargetSelector: """Class to hold a target selector for a service.""" - def __init__(self, service_call: ServiceCall): + def __init__(self, service_call: ServiceCall) -> None: """Extract ids from service call data.""" entity_ids: str | list | None = service_call.data.get(ATTR_ENTITY_ID) device_ids: str | list | None = service_call.data.get(ATTR_DEVICE_ID) diff --git a/homeassistant/helpers/storage.py b/homeassistant/helpers/storage.py index 456e9b04709..5700a7f854b 100644 --- a/homeassistant/helpers/storage.py +++ b/homeassistant/helpers/storage.py @@ -75,7 +75,7 @@ class Store: private: bool = False, *, encoder: type[JSONEncoder] | None = None, - ): + ) -> None: """Initialize storage class.""" self.version = version self.key = key diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index 40101e17128..86223d2a950 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -175,7 +175,7 @@ class TupleWrapper(tuple, ResultWrapper): # pylint: disable=super-init-not-called - def __init__(self, value: tuple, *, render_result: str | None = None): + def __init__(self, value: tuple, *, render_result: str | None = None) -> None: """Initialize a new tuple class.""" self.render_result = render_result diff --git a/homeassistant/helpers/trace.py b/homeassistant/helpers/trace.py index bfa713a3b2a..33fe76c9eab 100644 --- a/homeassistant/helpers/trace.py +++ b/homeassistant/helpers/trace.py @@ -15,7 +15,7 @@ import homeassistant.util.dt as dt_util class TraceElement: """Container for trace data.""" - def __init__(self, variables: TemplateVarsType, path: str): + def __init__(self, variables: TemplateVarsType, path: str) -> None: """Container for trace data.""" self._child_key: tuple[str, str] | None = None self._child_run_id: str | None = None diff --git a/homeassistant/helpers/update_coordinator.py b/homeassistant/helpers/update_coordinator.py index f3eea63b1d4..c15d6534626 100644 --- a/homeassistant/helpers/update_coordinator.py +++ b/homeassistant/helpers/update_coordinator.py @@ -42,7 +42,7 @@ class DataUpdateCoordinator(Generic[T]): update_interval: timedelta | None = None, update_method: Callable[[], Awaitable[T]] | None = None, request_refresh_debouncer: Debouncer | None = None, - ): + ) -> None: """Initialize global data updater.""" self.hass = hass self.logger = logger diff --git a/homeassistant/loader.py b/homeassistant/loader.py index adebe535f6a..444e35add33 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -305,7 +305,7 @@ class Integration: pkg_path: str, file_path: pathlib.Path, manifest: Manifest, - ): + ) -> None: """Initialize an integration.""" self.hass = hass self.pkg_path = pkg_path diff --git a/homeassistant/util/yaml/loader.py b/homeassistant/util/yaml/loader.py index dbff753aa68..5e98e4cfc6f 100644 --- a/homeassistant/util/yaml/loader.py +++ b/homeassistant/util/yaml/loader.py @@ -27,7 +27,7 @@ _LOGGER = logging.getLogger(__name__) class Secrets: """Store secrets while loading YAML.""" - def __init__(self, config_dir: Path): + def __init__(self, config_dir: Path) -> None: """Initialize secrets.""" self.config_dir = config_dir self._cache: dict[Path, dict[str, str]] = {}