Skip to content

Commit b20ab8e

Browse files
authored
Merge pull request #359 from plugwise/typing_suggestion
Typing suggestions
2 parents babb097 + 090690d commit b20ab8e

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Changelog
22

3+
## v0.31.8: Improve typing as per Core PR #96915
4+
35
## v0.31.7: Various small updates
46

57
- Repair coverage/fix testing - #294

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"package.json": "^2.0.1",
4-
"prettier": "^3.0.0-alpha.9-for-vscode"
3+
"package.json": "^0.0.0",
4+
"prettier": "^3.0.0"
55
}
66
}

plugwise/constants.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dataclasses import dataclass
66
import datetime as dt
77
import logging
8-
from typing import Final, TypedDict
8+
from typing import Final, Literal, TypedDict, get_args
99

1010
LOGGER = logging.getLogger(__name__)
1111

@@ -246,7 +246,7 @@
246246

247247
# All available Binary Sensor, Sensor, and Switch Types
248248

249-
BINARY_SENSORS: Final[tuple[str, ...]] = (
249+
BinarySensorType = Literal[
250250
"cooling_enabled",
251251
"compressor_state",
252252
"cooling_state",
@@ -255,9 +255,10 @@
255255
"heating_state",
256256
"plugwise_notification",
257257
"slave_boiler_state",
258-
)
258+
]
259+
BINARY_SENSORS: Final[tuple[str, ...]] = get_args(BinarySensorType)
259260

260-
SENSORS: Final[tuple[str, ...]] = (
261+
SensorType = Literal[
261262
"battery",
262263
"cooling_activation_outdoor_temperature",
263264
"cooling_deactivation_threshold",
@@ -309,14 +310,16 @@
309310
"voltage_phase_three",
310311
"water_pressure",
311312
"water_temperature",
312-
)
313+
]
314+
SENSORS: Final[tuple[str, ...]] = get_args(SensorType)
313315

314-
SWITCHES: Final[tuple[str, ...]] = (
316+
SwitchType = Literal[
315317
"cooling_ena_switch",
316318
"dhw_cm_switch",
317319
"lock",
318320
"relay",
319-
)
321+
]
322+
SWITCHES: Final[tuple[str, ...]] = get_args(SwitchType)
320323

321324

322325
class ApplianceData(TypedDict, total=False):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "plugwise"
7-
version = "0.31.7"
7+
version = "0.31.8"
88
license = {file = "LICENSE"}
99
description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3."
1010
readme = "README.md"

0 commit comments

Comments
 (0)