summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.eu>2018-12-12 21:55:00 +0100
committerDiego Elio Pettenò <flameeyes@flameeyes.eu>2018-12-12 21:55:00 +0100
commit4f4635e06b2ec0504bda0d6f2552bf72bb218aa0 (patch)
tree2ddf0077332498504a04a3aaa641d177b3bd7e9d
parentotverio2015: fix one remaining entry referencing the now-gone COMMAND_SUCCESS constant. (diff)
downloadglucometerutils-4f4635e06b2ec0504bda0d6f2552bf72bb218aa0.tar
glucometerutils-4f4635e06b2ec0504bda0d6f2552bf72bb218aa0.tar.gz
glucometerutils-4f4635e06b2ec0504bda0d6f2552bf72bb218aa0.tar.bz2
glucometerutils-4f4635e06b2ec0504bda0d6f2552bf72bb218aa0.tar.lz
glucometerutils-4f4635e06b2ec0504bda0d6f2552bf72bb218aa0.tar.xz
glucometerutils-4f4635e06b2ec0504bda0d6f2552bf72bb218aa0.tar.zst
glucometerutils-4f4635e06b2ec0504bda0d6f2552bf72bb218aa0.zip
-rw-r--r--.gitignore5
-rw-r--r--glucometerutils/support/freestyle.py8
-rw-r--r--glucometerutils/support/hiddevice.py13
-rw-r--r--glucometerutils/support/serial.py11
-rw-r--r--mypy.ini14
5 files changed, 38 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index 90d1a19..a9e5af7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,9 @@
+*.egg-info/
*.pyc
*~
+.cache
+.mypy_cache/
/MANIFEST
/dist/
__pycache__/
-.cache
build
-*.egg-info/
diff --git a/glucometerutils/support/freestyle.py b/glucometerutils/support/freestyle.py
index 7f9c7e8..3770b04 100644
--- a/glucometerutils/support/freestyle.py
+++ b/glucometerutils/support/freestyle.py
@@ -77,8 +77,8 @@ class FreeStyleHidDevice(hiddevice.HidDevice):
TEXT_CMD = 0x60
TEXT_REPLY_CMD = 0x60
- USB_VENDOR_ID = 0x1a61 # Abbott Diabetes Care
- USB_PRODUCT_ID = None
+ USB_VENDOR_ID = 0x1a61 # type: int # Abbott Diabetes Care
+ USB_PRODUCT_ID = None # type: int
def connect(self):
"""Open connection to the device, starting the knocking sequence."""
@@ -103,8 +103,8 @@ class FreeStyleHidDevice(hiddevice.HidDevice):
usb_packet = _FREESTYLE_MESSAGE.build(
{'message_type': message_type, 'command': command})
- logging.debug('Sending packet: %r', usb_packet)
-
+ logging.debug('Sending packet: %r', usb_packet
+)
self._write(usb_packet)
def _read_response(self):
diff --git a/glucometerutils/support/hiddevice.py b/glucometerutils/support/hiddevice.py
index 86203ba..07596c2 100644
--- a/glucometerutils/support/hiddevice.py
+++ b/glucometerutils/support/hiddevice.py
@@ -9,6 +9,11 @@ __license__ = 'MIT'
import logging
import os
+try:
+ from typing import Optional
+except:
+ pass
+
from glucometerutils import exceptions
@@ -33,14 +38,14 @@ class HidDevice(object):
Optional parameters available:
- TIMEOUT_MS: (int, default: NOne) the read timeout in milliseconds, used
+ TIMEOUT_MS: (int, default: None) the read timeout in milliseconds, used
for hidapi reads only. If -1, hidapi will be provided no timeout.
"""
- USB_VENDOR_ID = None
- USB_PRODUCT_ID = None
+ USB_VENDOR_ID = None # type: int
+ USB_PRODUCT_ID = None # type: int
- TIMEOUT_MS = None
+ TIMEOUT_MS = None # type: Optional[int]
def __init__(self, device):
if None in (self.USB_VENDOR_ID, self.USB_PRODUCT_ID) and not device:
diff --git a/glucometerutils/support/serial.py b/glucometerutils/support/serial.py
index ce4ac20..9d7694d 100644
--- a/glucometerutils/support/serial.py
+++ b/glucometerutils/support/serial.py
@@ -9,6 +9,11 @@ __license__ = 'MIT'
import logging
+try:
+ from typing import Text
+except:
+ pass
+
import serial
from glucometerutils import exceptions
@@ -40,10 +45,10 @@ class SerialDevice(object):
"""
- BAUDRATE = None
- DEFAULT_CABLE_ID = None
+ BAUDRATE = None # type: int
+ DEFAULT_CABLE_ID = None # type: Text
- TIMEOUT = 1
+ TIMEOUT = 1 # type: float
def __init__(self, device):
assert self.BAUDRATE is not None
diff --git a/mypy.ini b/mypy.ini
new file mode 100644
index 0000000..0d124c8
--- /dev/null
+++ b/mypy.ini
@@ -0,0 +1,14 @@
+[mypy]
+python_version = 3.7
+
+[mypy-serial]
+ignore_missing_imports = True
+
+[mypy-construct]
+ignore_missing_imports = True
+
+[mypy-hid]
+ignore_missing_imports = True
+
+[mypy-pyscsi.*]
+ignore_missing_imports = True