From 5f58bc8f72d3134665198e4223d354ba74ef978b Mon Sep 17 00:00:00 2001 From: Hans Erik van Elburg Date: Tue, 27 Dec 2022 18:58:48 +0100 Subject: [PATCH] add pylama back in + fix uniform style issues reported by pylama --- dsmr_parser/objects.py | 5 ++++- dsmr_parser/parsers.py | 8 ++++---- test/test_parse_fluvius.py | 1 - tox.ini | 17 +++++++++++++++++ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/dsmr_parser/objects.py b/dsmr_parser/objects.py index 510a77b..351b5c6 100644 --- a/dsmr_parser/objects.py +++ b/dsmr_parser/objects.py @@ -113,6 +113,7 @@ class MBusObject(DSMRObject): } return json.dumps(output) + class MBusObjectPeak(DSMRObject): @property @@ -132,7 +133,9 @@ class MBusObjectPeak(DSMRObject): return self.values[2]['unit'] def __str__(self): - output = "{}\t[{}] at {} occurred {}".format(str(self.value), str(self.unit), str(self.datetime.astimezone().isoformat()), str(self.occurred.astimezone().isoformat())) + output = "{}\t[{}] at {} occurred {}"\ + .format(str(self.value), str(self.unit), str(self.datetime.astimezone().isoformat()), + str(self.occurred.astimezone().isoformat())) return output def to_json(self): diff --git a/dsmr_parser/parsers.py b/dsmr_parser/parsers.py index 101d08f..9b10b4d 100644 --- a/dsmr_parser/parsers.py +++ b/dsmr_parser/parsers.py @@ -244,10 +244,10 @@ class MaxDemandParser(DSMRObjectParser): objects = [] count = int(values[0]) - for i in range(1, count+1): - timestamp_month = ValueParser(timestamp).parse(values[i*3+1]) - timestamp_occurred = ValueParser(timestamp).parse(values[i*3+1]) - value = ValueParser(Decimal).parse(values[i*3+2]) + for i in range(1, count + 1): + timestamp_month = ValueParser(timestamp).parse(values[i * 3 + 1]) + timestamp_occurred = ValueParser(timestamp).parse(values[i * 3 + 1]) + value = ValueParser(Decimal).parse(values[i * 3 + 2]) objects.append(MBusObjectPeak([timestamp_month, timestamp_occurred, value])) return objects diff --git a/test/test_parse_fluvius.py b/test/test_parse_fluvius.py index c530248..3213fd9 100644 --- a/test/test_parse_fluvius.py +++ b/test/test_parse_fluvius.py @@ -246,7 +246,6 @@ class TelegramParserFluviusTest(unittest.TestCase): assert isinstance(result[obis.BELGIUM_MBUS2_METER_READING1].value, Decimal) assert result[obis.BELGIUM_MBUS2_METER_READING1].value == Decimal('872.234') - def test_checksum_valid(self): # No exception is raised. TelegramParser.validate_checksum(TELEGRAM_FLUVIUS_V171) diff --git a/tox.ini b/tox.ini index da14c9a..533aa72 100644 --- a/tox.ini +++ b/tox.ini @@ -2,8 +2,25 @@ deps= pytest pytest-cov + pylama pytest-asyncio pytest-mock dlms_cosem commands= py.test --cov=dsmr_parser test {posargs} + pylama dsmr_parser test + +[pylama:dsmr_parser/clients/__init__.py] +ignore = W0611 + +[pylama:dsmr_parser/parsers.py] +ignore = W605 + +[pylama:test/example_telegrams.py] +ignore = E501 + +[pylama:pylint] +max_line_length = 120 + +[pylama:pycodestyle] +max_line_length = 120 \ No newline at end of file