summaryrefslogtreecommitdiffstats
path: root/glucometerutils/support
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.com>2023-08-03 12:26:51 +0200
committerDiego Elio Pettenò <flameeyes@flameeyes.com>2023-08-03 12:47:49 +0200
commit093a39d72dbc7d18c0aacbdd5a4ba6a04cd64f95 (patch)
tree69db3bac569d41ef0e073ac36d2b66144417e6e2 /glucometerutils/support
parentUpdate minimum supported Python version to 3.9. (diff)
downloadglucometerutils-093a39d72dbc7d18c0aacbdd5a4ba6a04cd64f95.tar
glucometerutils-093a39d72dbc7d18c0aacbdd5a4ba6a04cd64f95.tar.gz
glucometerutils-093a39d72dbc7d18c0aacbdd5a4ba6a04cd64f95.tar.bz2
glucometerutils-093a39d72dbc7d18c0aacbdd5a4ba6a04cd64f95.tar.lz
glucometerutils-093a39d72dbc7d18c0aacbdd5a4ba6a04cd64f95.tar.xz
glucometerutils-093a39d72dbc7d18c0aacbdd5a4ba6a04cd64f95.tar.zst
glucometerutils-093a39d72dbc7d18c0aacbdd5a4ba6a04cd64f95.zip
Diffstat (limited to 'glucometerutils/support')
-rw-r--r--glucometerutils/support/contourusb.py9
-rw-r--r--glucometerutils/support/freestyle_libre.py9
-rw-r--r--glucometerutils/support/hiddevice.py4
3 files changed, 12 insertions, 10 deletions
diff --git a/glucometerutils/support/contourusb.py b/glucometerutils/support/contourusb.py
index c61ab41..259e8d1 100644
--- a/glucometerutils/support/contourusb.py
+++ b/glucometerutils/support/contourusb.py
@@ -15,7 +15,8 @@ http://protocols.ascensia.com/Programming-Guide.aspx
import datetime
import enum
import re
-from typing import Dict, Generator, List, Optional, Tuple
+from collections.abc import Generator
+from typing import Optional
from glucometerutils import driver
from glucometerutils.support import hiddevice
@@ -80,7 +81,7 @@ class ContourHidDevice(driver.GlucometerDevice):
currecno: Optional[int] = None
- def __init__(self, usb_ids: Tuple[int, int], device_path: Optional[str]) -> None:
+ def __init__(self, usb_ids: tuple[int, int], device_path: Optional[str]) -> None:
super().__init__(device_path)
self._hid_session = hiddevice.HidSession(usb_ids, device_path)
@@ -315,13 +316,13 @@ class ContourHidDevice(driver.GlucometerDevice):
except Exception as e:
raise e
- def parse_result_record(self, text: str) -> Dict[str, str]:
+ def parse_result_record(self, text: str) -> dict[str, str]:
result = _RESULT_RECORD_RE.search(text)
assert result is not None
rec_text = result.groupdict()
return rec_text
- def _get_multirecord(self) -> List[Dict[str, str]]:
+ def _get_multirecord(self) -> list[dict[str, str]]:
"""Queries for, and returns, "multirecords" results.
Returns:
diff --git a/glucometerutils/support/freestyle_libre.py b/glucometerutils/support/freestyle_libre.py
index 46ecf15..b231449 100644
--- a/glucometerutils/support/freestyle_libre.py
+++ b/glucometerutils/support/freestyle_libre.py
@@ -12,7 +12,8 @@ https://protocols.glucometers.tech/abbott/freestyle-libre
import datetime
import logging
-from typing import Dict, Generator, Mapping, Optional, Sequence, Tuple, Type
+from collections.abc import Generator, Mapping, Sequence
+from typing import Optional
from glucometerutils import common, exceptions
from glucometerutils.support import freestyle
@@ -67,8 +68,8 @@ _ARRESULT_RAPID_INSULIN_ENTRY_MAP = ((43, "double-rapid-acting-insulin"),)
def _parse_record(
- record: Sequence[str], entry_map: Sequence[Tuple[int, str]]
-) -> Dict[str, int]:
+ record: Sequence[str], entry_map: Sequence[tuple[int, str]]
+) -> dict[str, int]:
"""Parses a list of string fields into a dictionary of integers."""
if not record:
@@ -127,7 +128,7 @@ def _parse_arresult(record: Sequence[str]) -> Optional[common.AnyReading]:
comment_parts = []
measure_method: Optional[common.MeasurementMethod] = None
- cls: Optional[Type[common.AnyReading]] = None
+ cls: Optional[type[common.AnyReading]] = None
value: Optional[float] = None
if parsed_record["reading-type"] == 2:
diff --git a/glucometerutils/support/hiddevice.py b/glucometerutils/support/hiddevice.py
index bd35a8f..eb069df 100644
--- a/glucometerutils/support/hiddevice.py
+++ b/glucometerutils/support/hiddevice.py
@@ -7,7 +7,7 @@
import logging
import os
-from typing import BinaryIO, Optional, Tuple
+from typing import BinaryIO, Optional
from glucometerutils import exceptions
@@ -23,7 +23,7 @@ class HidSession:
def __init__(
self,
- usb_id: Optional[Tuple[int, int]],
+ usb_id: Optional[tuple[int, int]],
device: Optional[str],
timeout_ms: int = 0,
) -> None: