diff --git a/Dockerfile b/Dockerfile index a3f68ea..e2ec50f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,8 @@ pip3 install \ certifi==2020.12.5 chardet==4.0.0 idna==2.10 urllib3==1.26.4 \ six==1.15.0 msgpack==1.0.2 \ influxdb_client==1.24.0 rx==3.2.0 \ - yagrc==1.1.1 grpcio-reflection==1.36.1 protobuf==3.15.6 + yagrc==1.1.1 grpcio-reflection==1.36.1 protobuf==3.15.6 \ + typing-extensions==4.3.0 ADD . /app WORKDIR /app diff --git a/packaging/setup.cfg b/packaging/setup.cfg index 2c0b772..b740447 100644 --- a/packaging/setup.cfg +++ b/packaging/setup.cfg @@ -19,6 +19,7 @@ install_requires = grpcio>=1.12.0 protobuf>=3.6.0 yagrc>=1.1.1 + typing-extensions>=4.3.0 package_dir = =.. py_modules = diff --git a/requirements.txt b/requirements.txt index f1b25eb..f401847 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ paho-mqtt>=1.5.1 influxdb>=5.3.1 influxdb_client>=1.23.0 pypng>=0.0.20 +typing-extensions>=4.3.0 \ No newline at end of file diff --git a/starlink_grpc.py b/starlink_grpc.py index 55da404..9dd4463 100644 --- a/starlink_grpc.py +++ b/starlink_grpc.py @@ -362,18 +362,8 @@ period. from itertools import chain import math import statistics -from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, get_type_hints -try: - from typing import TypedDict, get_args -except ImportError: - # Python 3.7 does not have TypedDict, so fake it so the run time still - # works, even though static type checker probably will not. - def TypedDict(name, types): # pylint: disable=invalid-name - return type(name, (dict,), {"__annotations__": types}) - - def get_args(tp: Any) -> Tuple[Any, ...]: - return tp.__args__ - +from typing import Dict, Iterable, List, Optional, Sequence, Tuple, get_type_hints +from typing_extensions import TypedDict, get_args import grpc @@ -549,7 +539,9 @@ class GrpcError(Exception): class UnwrappedHistory: - """Empty class for holding a copy of grpc history data.""" + """Class for holding a copy of grpc history data.""" + + unwrapped: bool class ChannelContext: @@ -1031,7 +1023,7 @@ def concatenate_history(history1, history2, samples1: int = -1, start1: Optional print("WARNING: Appending discontiguous samples. Polling interval probably too short.") new_samples = size2 - unwrapped: Any = UnwrappedHistory() + unwrapped = UnwrappedHistory() for field in HISTORY_FIELDS: setattr(unwrapped, field, []) unwrapped.unwrapped = True