Add missing return type in Core constructors (#50884)

This commit is contained in:
Ruslan Sayfutdinov 2021-05-20 16:53:29 +01:00 committed by GitHub
parent cf228e3fe5
commit 391b2f8ccd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 29 additions and 25 deletions

View file

@ -79,7 +79,7 @@ async def auth_manager_from_config(
class AuthManagerFlowManager(data_entry_flow.FlowManager): class AuthManagerFlowManager(data_entry_flow.FlowManager):
"""Manage authentication flows.""" """Manage authentication flows."""
def __init__(self, hass: HomeAssistant, auth_manager: AuthManager): def __init__(self, hass: HomeAssistant, auth_manager: AuthManager) -> None:
"""Init auth manager flows.""" """Init auth manager flows."""
super().__init__(hass) super().__init__(hass)
self.auth_manager = auth_manager self.auth_manager = auth_manager

View file

@ -569,7 +569,7 @@ class ConfigEntriesFlowManager(data_entry_flow.FlowManager):
def __init__( def __init__(
self, hass: HomeAssistant, config_entries: ConfigEntries, hass_config: dict self, hass: HomeAssistant, config_entries: ConfigEntries, hass_config: dict
): ) -> None:
"""Initialize the config entry flow manager.""" """Initialize the config entry flow manager."""
super().__init__(hass) super().__init__(hass)
self.config_entries = config_entries self.config_entries = config_entries

View file

@ -163,7 +163,7 @@ class HassJob:
__slots__ = ("job_type", "target") __slots__ = ("job_type", "target")
def __init__(self, target: Callable): def __init__(self, target: Callable) -> None:
"""Create a job object.""" """Create a job object."""
if asyncio.iscoroutine(target): if asyncio.iscoroutine(target):
raise ValueError("Coroutine not allowed to be passed to HassJob") raise ValueError("Coroutine not allowed to be passed to HassJob")

View file

@ -44,7 +44,9 @@ class UnknownStep(FlowError):
class AbortFlow(FlowError): class AbortFlow(FlowError):
"""Exception to indicate a flow needs to be aborted.""" """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.""" """Initialize an abort flow exception."""
super().__init__(f"Flow aborted: {reason}") super().__init__(f"Flow aborted: {reason}")
self.reason = reason self.reason = reason

View file

@ -66,7 +66,7 @@ class CollectionError(HomeAssistantError):
class ItemNotFound(CollectionError): class ItemNotFound(CollectionError):
"""Raised when an item is not found.""" """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.""" """Initialize item not found error."""
super().__init__(f"Item {item_id} not found.") super().__init__(f"Item {item_id} not found.")
self.item_id = item_id self.item_id = item_id
@ -103,7 +103,9 @@ class IDManager:
class ObservableCollection(ABC): class ObservableCollection(ABC):
"""Base collection type that can be observed.""" """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.""" """Initialize the base collection."""
self.logger = logger self.logger = logger
self.id_manager = id_manager or IDManager() self.id_manager = id_manager or IDManager()
@ -190,7 +192,7 @@ class StorageCollection(ObservableCollection):
store: Store, store: Store,
logger: logging.Logger, logger: logging.Logger,
id_manager: IDManager | None = None, id_manager: IDManager | None = None,
): ) -> None:
"""Initialize the storage collection.""" """Initialize the storage collection."""
super().__init__(logger, id_manager) super().__init__(logger, id_manager)
self.store = store self.store = store
@ -389,7 +391,7 @@ class StorageCollectionWebsocket:
model_name: str, model_name: str,
create_schema: dict, create_schema: dict,
update_schema: dict, update_schema: dict,
): ) -> None:
"""Initialize a websocket CRUD.""" """Initialize a websocket CRUD."""
self.storage_collection = storage_collection self.storage_collection = storage_collection
self.api_prefix = api_prefix self.api_prefix = api_prefix

View file

@ -107,7 +107,7 @@ class LocalOAuth2Implementation(AbstractOAuth2Implementation):
client_secret: str, client_secret: str,
authorize_url: str, authorize_url: str,
token_url: str, token_url: str,
): ) -> None:
"""Initialize local auth implementation.""" """Initialize local auth implementation."""
self.hass = hass self.hass = hass
self._domain = domain self._domain = domain
@ -437,7 +437,7 @@ class OAuth2Session:
hass: HomeAssistant, hass: HomeAssistant,
config_entry: config_entries.ConfigEntry, config_entry: config_entries.ConfigEntry,
implementation: AbstractOAuth2Implementation, implementation: AbstractOAuth2Implementation,
): ) -> None:
"""Initialize an OAuth2 session.""" """Initialize an OAuth2 session."""
self.hass = hass self.hass = hass
self.config_entry = config_entry self.config_entry = config_entry

View file

@ -20,7 +20,7 @@ class Debouncer:
cooldown: float, cooldown: float,
immediate: bool, immediate: bool,
function: Callable[..., Awaitable[Any]] | None = None, function: Callable[..., Awaitable[Any]] | None = None,
): ) -> None:
"""Initialize debounce. """Initialize debounce.
immediate: indicate if the function needs to be called right away and immediate: indicate if the function needs to be called right away and

View file

@ -76,7 +76,7 @@ class EntityComponent:
domain: str, domain: str,
hass: HomeAssistant, hass: HomeAssistant,
scan_interval: timedelta = DEFAULT_SCAN_INTERVAL, scan_interval: timedelta = DEFAULT_SCAN_INTERVAL,
): ) -> None:
"""Initialize an entity component.""" """Initialize an entity component."""
self.logger = logger self.logger = logger
self.hass = hass self.hass = hass

View file

@ -85,7 +85,7 @@ class EntityPlatform:
platform: ModuleType | None, platform: ModuleType | None,
scan_interval: timedelta, scan_interval: timedelta,
entity_namespace: str | None, entity_namespace: str | None,
): ) -> None:
"""Initialize the entity platform.""" """Initialize the entity platform."""
self.hass = hass self.hass = hass
self.logger = logger self.logger = logger

View file

@ -146,7 +146,7 @@ class RegistryEntry:
class EntityRegistry: class EntityRegistry:
"""Class to hold a registry of entities.""" """Class to hold a registry of entities."""
def __init__(self, hass: HomeAssistant): def __init__(self, hass: HomeAssistant) -> None:
"""Initialize the registry.""" """Initialize the registry."""
self.hass = hass self.hass = hass
self.entities: dict[str, RegistryEntry] self.entities: dict[str, RegistryEntry]

View file

@ -534,7 +534,7 @@ class _TrackStateChangeFiltered:
hass: HomeAssistant, hass: HomeAssistant,
track_states: TrackStates, track_states: TrackStates,
action: Callable[[Event], Any], action: Callable[[Event], Any],
): ) -> None:
"""Handle removal / refresh of tracker init.""" """Handle removal / refresh of tracker init."""
self.hass = hass self.hass = hass
self._action = action self._action = action
@ -775,7 +775,7 @@ class _TrackTemplateResultInfo:
hass: HomeAssistant, hass: HomeAssistant,
track_templates: Iterable[TrackTemplate], track_templates: Iterable[TrackTemplate],
action: Callable, action: Callable,
): ) -> None:
"""Handle removal / refresh of tracker init.""" """Handle removal / refresh of tracker init."""
self.hass = hass self.hass = hass
self._job = HassJob(action) self._job = HassJob(action)

View file

@ -19,7 +19,7 @@ class KeyedRateLimit:
def __init__( def __init__(
self, self,
hass: HomeAssistant, hass: HomeAssistant,
): ) -> None:
"""Initialize ratelimit tracker.""" """Initialize ratelimit tracker."""
self.hass = hass self.hass = hass
self._last_triggered: dict[Hashable, datetime] = {} self._last_triggered: dict[Hashable, datetime] = {}

View file

@ -12,7 +12,7 @@ from . import template
class ScriptVariables: class ScriptVariables:
"""Class to hold and render script variables.""" """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.""" """Initialize script variables."""
self.variables = variables self.variables = variables
self._has_template: bool | None = None self._has_template: bool | None = None

View file

@ -73,7 +73,7 @@ class ServiceParams(TypedDict):
class ServiceTargetSelector: class ServiceTargetSelector:
"""Class to hold a target selector for a service.""" """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.""" """Extract ids from service call data."""
entity_ids: str | list | None = service_call.data.get(ATTR_ENTITY_ID) entity_ids: str | list | None = service_call.data.get(ATTR_ENTITY_ID)
device_ids: str | list | None = service_call.data.get(ATTR_DEVICE_ID) device_ids: str | list | None = service_call.data.get(ATTR_DEVICE_ID)

View file

@ -75,7 +75,7 @@ class Store:
private: bool = False, private: bool = False,
*, *,
encoder: type[JSONEncoder] | None = None, encoder: type[JSONEncoder] | None = None,
): ) -> None:
"""Initialize storage class.""" """Initialize storage class."""
self.version = version self.version = version
self.key = key self.key = key

View file

@ -175,7 +175,7 @@ class TupleWrapper(tuple, ResultWrapper):
# pylint: disable=super-init-not-called # 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.""" """Initialize a new tuple class."""
self.render_result = render_result self.render_result = render_result

View file

@ -15,7 +15,7 @@ import homeassistant.util.dt as dt_util
class TraceElement: class TraceElement:
"""Container for trace data.""" """Container for trace data."""
def __init__(self, variables: TemplateVarsType, path: str): def __init__(self, variables: TemplateVarsType, path: str) -> None:
"""Container for trace data.""" """Container for trace data."""
self._child_key: tuple[str, str] | None = None self._child_key: tuple[str, str] | None = None
self._child_run_id: str | None = None self._child_run_id: str | None = None

View file

@ -42,7 +42,7 @@ class DataUpdateCoordinator(Generic[T]):
update_interval: timedelta | None = None, update_interval: timedelta | None = None,
update_method: Callable[[], Awaitable[T]] | None = None, update_method: Callable[[], Awaitable[T]] | None = None,
request_refresh_debouncer: Debouncer | None = None, request_refresh_debouncer: Debouncer | None = None,
): ) -> None:
"""Initialize global data updater.""" """Initialize global data updater."""
self.hass = hass self.hass = hass
self.logger = logger self.logger = logger

View file

@ -305,7 +305,7 @@ class Integration:
pkg_path: str, pkg_path: str,
file_path: pathlib.Path, file_path: pathlib.Path,
manifest: Manifest, manifest: Manifest,
): ) -> None:
"""Initialize an integration.""" """Initialize an integration."""
self.hass = hass self.hass = hass
self.pkg_path = pkg_path self.pkg_path = pkg_path

View file

@ -27,7 +27,7 @@ _LOGGER = logging.getLogger(__name__)
class Secrets: class Secrets:
"""Store secrets while loading YAML.""" """Store secrets while loading YAML."""
def __init__(self, config_dir: Path): def __init__(self, config_dir: Path) -> None:
"""Initialize secrets.""" """Initialize secrets."""
self.config_dir = config_dir self.config_dir = config_dir
self._cache: dict[Path, dict[str, str]] = {} self._cache: dict[Path, dict[str, str]] = {}