Add Self typing (4) [mypy 1.0] (#87601)

This commit is contained in:
Marc Mueller 2023-02-07 05:30:22 +01:00 committed by GitHub
parent f7b39aa4a8
commit ea4e2ab4aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 32 additions and 19 deletions

View file

@ -5,6 +5,7 @@ from collections.abc import Callable
from datetime import datetime, timedelta
import logging
from typing_extensions import Self
import voluptuous as vol
from homeassistant.const import (
@ -207,14 +208,14 @@ class Timer(collection.CollectionEntity, RestoreEntity):
self._attr_force_update = True
@classmethod
def from_storage(cls, config: ConfigType) -> Timer:
def from_storage(cls, config: ConfigType) -> Self:
"""Return entity instance initialized from storage."""
timer = cls(config)
timer.editable = True
return timer
@classmethod
def from_yaml(cls, config: ConfigType) -> Timer:
def from_yaml(cls, config: ConfigType) -> Self:
"""Return entity instance initialized from yaml."""
timer = cls(config)
timer.entity_id = ENTITY_ID_FORMAT.format(config[CONF_ID])