Skip to content

Commit

Permalink
add deprecate msg for xxxId attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdavb committed Sep 1, 2024
1 parent e850230 commit 40e86e1
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
13 changes: 11 additions & 2 deletions src/evohomeasync2/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Final
from typing import TYPE_CHECKING, Final, NoReturn

from . import exceptions as exc
from .schema import SCH_GWY_STATUS
from .schema.const import (
SZ_GATEWAY,
Expand All @@ -25,7 +26,15 @@
from .schema import _EvoDictT


class Gateway(ActiveFaultsBase, EntityBase):
class _GatewayDeprecated: # pragma: no cover
"""Deprecated attributes and methods removed from the evohome-client namespace."""

@property
def systemId(self) -> NoReturn: # noqa: N802
raise exc.DeprecationError(f"{self}: .gatewayId is deprecated, use .id")


class Gateway(_GatewayDeprecated, ActiveFaultsBase, EntityBase):
"""Instance of a location's gateway."""

STATUS_SCHEMA: Final[vol.Schema] = SCH_GWY_STATUS
Expand Down
4 changes: 0 additions & 4 deletions src/evohomeasync2/hotwater.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
class _HotWaterDeprecated: # pragma: no cover
"""Deprecated attributes and methods removed from the evohome-client namespace."""

@property
def zoneId(self) -> NoReturn: # noqa: N802
raise exc.DeprecationError(f"{self}: .zoneId is deprecated, use .id")

async def get_dhw_state(self, *args: Any, **kwargs: Any) -> NoReturn:
raise exc.DeprecationError(
f"{self}: .get_dhw_state() is deprecated, use Location.refresh_status()"
Expand Down
4 changes: 4 additions & 0 deletions src/evohomeasync2/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
class _LocationDeprecated: # pragma: no cover
"""Deprecated attributes and methods removed from the evohome-client namespace."""

@property
def locationId(self) -> NoReturn: # noqa: N802
raise exc.DeprecationError(f"{self}: .locationId is deprecated, use .id")

async def status(self, *args: Any, **kwargs: Any) -> NoReturn:
raise exc.DeprecationError(
f"{self}: .status() is deprecated, use .refresh_status()"
Expand Down
4 changes: 4 additions & 0 deletions src/evohomeasync2/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
class _SystemDeprecated: # pragma: no cover
"""Deprecated attributes and methods removed from the evohome-client namespace."""

@property
def systemId(self) -> NoReturn: # noqa: N802
raise exc.DeprecationError(f"{self}: .systemId is deprecated, use .id")

async def set_status_reset(self, *args: Any, **kwargs: Any) -> NoReturn:
raise exc.DeprecationError(
f"{self}: .set_status_reset() is deprecrated, use .reset_mode()"
Expand Down
4 changes: 4 additions & 0 deletions src/evohomeasync2/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def log_as_resolved(fault: _EvoDictT) -> None:
class _ZoneBaseDeprecated: # pragma: no cover
"""Deprecated attributes and methods removed from the evohome-client namespace."""

@property
def zoneId(self) -> NoReturn: # noqa: N802
raise exc.DeprecationError(f"{self}: .zoneId is deprecated, use .id")

async def schedule(self) -> NoReturn:
raise exc.DeprecationError(
f"{self}: .schedule() is deprecrated, use .get_schedule()"
Expand Down
5 changes: 4 additions & 1 deletion tests/tests/test_installs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
from pytest_snapshot.plugin import Snapshot # type: ignore[import-untyped]


_DEPRECATED_ATTRS = ("locationId", "gatewayId", "systemId", "zoneId", "zone_type")


def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
folders = [
p.name
Expand All @@ -36,7 +39,7 @@ def obj_to_dict(obj: object) -> dict[str, Any]:
return {
attr: getattr(obj, attr)
for attr in get_property_methods(obj)
if attr not in ("zoneId", "zone_type") # excl. deprecated attrs
if attr not in _DEPRECATED_ATTRS
}

with patch("evohomeasync2.broker.Broker.get", broker_get(install)):
Expand Down

0 comments on commit 40e86e1

Please sign in to comment.