Skip to content

Commit 94c18c4

Browse files
Remove typing.Annotated
1 parent 7be75c5 commit 94c18c4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

streams/volume_synchronizer.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import queue
66
import logging
77
import sys
8-
from typing import Callable, List, Annotated
8+
from typing import Callable, List, Optional
99
from enum import Enum
1010
import requests
1111

@@ -29,14 +29,25 @@ def __init__(self):
2929
self.schedule_event: Callable[[VolEvents]]
3030
"""Event scheduler function provided by VolumeSynchronizer, has limited valid inputs that can be seen in the VolEvents enum"""
3131

32-
self.volume: Annotated[float | None, "float 0 <= value <= 1 or None"] = None
32+
self._volume: float = None
3333
"""Value between 0 and 1, or None if not yet initialized by the upstream"""
3434

3535
self.logger: logging.Logger
3636
"""logging.Logger instance provided by VolumeSynchronizer,"""
3737

3838
self.thread: threading.Thread = threading.Thread(target=self.run_async_watch, daemon=True).start()
3939

40+
@property
41+
def volume(self) -> Optional[float]:
42+
"""Value between 0 and 1, or None if not yet initialized by the upstream"""
43+
return self._volume
44+
45+
@volume.setter
46+
def volume(self, value: float) -> None:
47+
if 0 > value or value > 1:
48+
raise ValueError("Volume must be between 0 and 1")
49+
self._volume = value
50+
4051
def run_async_watch(self):
4152
"""Middleman function for creating an asyncio run inside of a new threading.Thread"""
4253
asyncio.run(self.watch_vol())

0 commit comments

Comments
 (0)