diff options
author | Diego Elio Pettenò <flameeyes@flameeyes.eu> | 2018-12-12 22:29:59 +0100 |
---|---|---|
committer | Diego Elio Pettenò <flameeyes@flameeyes.eu> | 2018-12-12 22:29:59 +0100 |
commit | 25d8e64a0676b78c42a210846b31d0279664e112 (patch) | |
tree | cdf56cacc88689302db8ce573f31ff61fbab6aba /glucometerutils/common.py | |
parent | Fix indentation of common.py. (diff) | |
download | glucometerutils-25d8e64a0676b78c42a210846b31d0279664e112.tar glucometerutils-25d8e64a0676b78c42a210846b31d0279664e112.tar.gz glucometerutils-25d8e64a0676b78c42a210846b31d0279664e112.tar.bz2 glucometerutils-25d8e64a0676b78c42a210846b31d0279664e112.tar.lz glucometerutils-25d8e64a0676b78c42a210846b31d0279664e112.tar.xz glucometerutils-25d8e64a0676b78c42a210846b31d0279664e112.tar.zst glucometerutils-25d8e64a0676b78c42a210846b31d0279664e112.zip |
Diffstat (limited to 'glucometerutils/common.py')
-rw-r--r-- | glucometerutils/common.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/glucometerutils/common.py b/glucometerutils/common.py index 1645c8c..8ffa724 100644 --- a/glucometerutils/common.py +++ b/glucometerutils/common.py @@ -12,7 +12,7 @@ import enum import textwrap try: - from typing import Text + from typing import Sequence, Text except: pass @@ -37,6 +37,7 @@ class MeasurementMethod(enum.Enum): def convert_glucose_unit(value, from_unit, to_unit): + # type: (float, Unit, Unit) -> float """Convert the given value of glucose level between units. Args: @@ -72,6 +73,7 @@ class GlucoseReading: MeasurementMethod)) # type: MeasurementMethod def get_value_as(self, to_unit): + # type: (Unit) -> float """Returns the reading value as the given unit. Args: @@ -80,6 +82,7 @@ class GlucoseReading: return convert_glucose_unit(self.value, Unit.MG_DL, to_unit) def as_csv(self, unit): + # type: (Unit) -> Text """Returns the reading as a formatted comma-separated value string.""" return '"%s","%.2f","%s","%s","%s"' % ( self.timestamp, self.get_value_as(unit), self.meal.value, @@ -112,11 +115,11 @@ class MeterInfo: the device. It can include hardware and software version. native_unit: One of the Unit values to identify the meter native unit. """ - model = attr.ib() - serial_number = attr.ib(default='N/A') - version_info = attr.ib(default=()) + model = attr.ib() # Text + serial_number = attr.ib(default='N/A') # Text + version_info = attr.ib(default=()) # Sequence[Text] native_unit = attr.ib( - default=Unit.MG_DL, validator=attr.validators.in_(Unit)) + default=Unit.MG_DL, validator=attr.validators.in_(Unit)) # Unit def __str__(self): version_information_string = 'N/A' |