Skip to content

Commit

Permalink
use NewType instead of TypeAlias
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdavb committed Jun 29, 2024
1 parent 6458db4 commit 93b29aa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions src/evohomeasync/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
import logging
from datetime import datetime as dt
from http import HTTPMethod, HTTPStatus
from typing import Any, Final, TypeAlias
from typing import Any, Final, NewType

import aiohttp

from . import exceptions as exc
from .schema import SZ_SESSION_ID, SZ_USER_ID, SZ_USER_INFO

_SessionIdT: TypeAlias = str
_UserIdT: TypeAlias = int
_SessionIdT = NewType("_SessionIdT", str)
_UserIdT = NewType("_UserIdT", int)

_UserInfoT: TypeAlias = dict[str, bool | int | str]
_UserDataT: TypeAlias = dict[str, _SessionIdT | _UserInfoT]
_LocnDataT: TypeAlias = dict[str, Any]
_UserInfoT = NewType("_UserInfoT", dict[str, bool | int | str])
_UserDataT = NewType("_UserDataT", dict[str, _SessionIdT | _UserInfoT])
_LocnDataT = NewType("_LocnDataT", dict[str, Any])


URL_HOST = "https://tccna.honeywell.com"
Expand Down
32 changes: 16 additions & 16 deletions src/evohomeasync/schema.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#!/usr/bin/env python3
"""evohomeasync provides an async client for the *original* Evohome API."""

from typing import Any, Final, TypeAlias
from typing import Any, Final, NewType

# TCC config, status dicts
_EvoLeafT: TypeAlias = bool | float | int | str | list[str] # Any
_DeviceDictT: TypeAlias = dict[str, Any] # '_EvoDeviceT' | _EvoLeafT]
_EvoDictT: TypeAlias = dict[str, Any] # '_EvoDictT' | _EvoLeafT]
_EvoListT: TypeAlias = list[_EvoDictT]
_EvoSchemaT: TypeAlias = _EvoDictT | _EvoListT
_EvoLeafT = NewType("_EvoLeafT", bool | float | int | str | list[str]) # Any
_DeviceDictT = NewType("_DeviceDictT", dict[str, Any]) # '_EvoDeviceT' | _EvoLeafT]
_EvoDictT = NewType("_EvoDictT", dict[str, Any]) # '_EvoDictT' | _EvoLeafT]
_EvoListT = NewType("_EvoListT", list[_EvoDictT])
_EvoSchemaT = NewType("_EvoSchemaT", _EvoDictT | _EvoListT)

# TCC identifiers (Usr, Loc, Gwy, Sys, Zon|Dhw)
_DhwIdT: TypeAlias = int
_GatewayIdT: TypeAlias = int
_LocationIdT: TypeAlias = int
_SystemIdT: TypeAlias = int
_UserIdT: TypeAlias = int
_ZoneIdT: TypeAlias = int
_ZoneNameT: TypeAlias = str
_DhwIdT = NewType("_DhwIdT", int)
_GatewayIdT = NewType("_GatewayIdT", int)
_LocationIdT = NewType("_LocationIdT", int)
_SystemIdT = NewType("_SystemIdT", int)
_UserIdT = NewType("_UserIdT", int)
_ZoneIdT = NewType("_ZoneIdT", int)
_ZoneNameT = NewType("_ZoneNameT", str)

# TCC other
_ModeT: TypeAlias = str
_SystemModeT: TypeAlias = str
_ModeT = NewType("_ModeT", str)
_SystemModeT = NewType("_SystemModeT", str)

_TaskIdT: TypeAlias = str # TODO: int or str?
_TaskIdT = NewType("_TaskIdT", str) # TODO: int or str?


SZ_SESSION_ID: Final = "sessionId" # id Id, not ID
Expand Down

0 comments on commit 93b29aa

Please sign in to comment.