Skip to content

Commit

Permalink
fix: awesomeversion not imported on config_flow
Browse files Browse the repository at this point in the history
refactor: add dataclass params

refactor: changed typehints for config flow
  • Loading branch information
alryaz committed Feb 6, 2025
1 parent 58db519 commit 062a473
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion custom_components/pandora_cas/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
_LOGGER: Final = logging.getLogger(__name__)


@dataclass
@dataclass(frozen=True, kw_only=True)
class PandoraCASButtonEntityDescription(
PandoraCASEntityDescription, ButtonEntityDescription
):
Expand Down
8 changes: 5 additions & 3 deletions custom_components/pandora_cas/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

import homeassistant.helpers.config_validation as cv
import voluptuous as vol
from awesomeversion import AwesomeVersion
from homeassistant.config_entries import (
ConfigFlow,
ConfigEntry,
OptionsFlow,
SOURCE_IMPORT,
ConfigFlowResult,
)
from homeassistant.const import (
CONF_PASSWORD,
Expand Down Expand Up @@ -105,7 +107,7 @@ def __init__(self) -> None:

async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
if user_input is not None:
account = PandoraOnlineAccount(
username=user_input[CONF_USERNAME],
Expand Down Expand Up @@ -191,7 +193,7 @@ async def async_step_user(
# noinspection PyUnusedLocal
async def async_step_reauth(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
if (
entry := self.hass.config_entries.async_get_entry(self.context["entry_id"])
).source == SOURCE_IMPORT:
Expand All @@ -201,7 +203,7 @@ async def async_step_reauth(

async def async_step_import(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
if user_input is None:
_LOGGER.error("Called import step without configuration")
return self.async_abort("empty_configuration_import")
Expand Down
10 changes: 5 additions & 5 deletions custom_components/pandora_cas/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ async def async_platform_setup_entry(
return True


@dataclass
@dataclass(frozen=True, kw_only=True)
class PandoraCASEntityDescription(EntityDescription):
attribute: str | MemberDescriptorType | None = None
attribute_source: str | MemberDescriptorType | None = "state"
Expand All @@ -209,11 +209,11 @@ class PandoraCASEntityDescription(EntityDescription):
def __post_init__(self):
"""Set translation key to entity description key."""
if isinstance(self.attribute, MemberDescriptorType):
self.attribute = self.attribute.__name__
object.__setattr__(self, "attribute", self.attribute.__name__)
if isinstance(self.attribute_source, MemberDescriptorType):
self.attribute_source = self.attribute_source.__name__
object.__setattr__(self, "attribute_source", self.attribute_source.__name__)
if not self.translation_key:
self.translation_key = self.key
object.__setattr__(self, "translation_key", self.key)


class BasePandoraCASEntity(Entity):
Expand Down Expand Up @@ -513,7 +513,7 @@ async def async_will_remove_from_hass(self) -> None:
self._command_listeners = None


@dataclass
@dataclass(frozen=True, kw_only=True)
class PandoraCASBooleanEntityDescription(PandoraCASEntityDescription):
icon_on: str | None = None
icon_off: str | None = None
Expand Down
2 changes: 1 addition & 1 deletion custom_components/pandora_cas/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
_LOGGER: Final = logging.getLogger(__name__)


@dataclass
@dataclass(frozen=True, kw_only=True)
class PandoraCASLockEntityDescription(
PandoraCASBooleanEntityDescription, LockEntityDescription
):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/pandora_cas/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
_LOGGER: Final = logging.getLogger(__name__)


@dataclass
@dataclass(frozen=True, kw_only=True)
class PandoraCASNumberEntityDescription(
PandoraCASEntityDescription, NumberEntityDescription
):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/pandora_cas/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
_LOGGER = logging.getLogger(__name__)


@dataclass
@dataclass(frozen=True, kw_only=True)
class PandoraCASSensorEntityDescription(
PandoraCASEntityDescription, SensorEntityDescription
):
Expand Down

0 comments on commit 062a473

Please sign in to comment.