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):
"""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

View File

@ -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

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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)

View File

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

View File

@ -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

View File

@ -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)

View File

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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]] = {}