From 8dee5edb0dcb2aaa673192b75776821e125bd47b Mon Sep 17 00:00:00 2001 From: Nigel Dokter Date: Sun, 12 Feb 2023 18:40:52 +0100 Subject: [PATCH] issue-51-telegram code style --- dsmr_parser/objects.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dsmr_parser/objects.py b/dsmr_parser/objects.py index b6455e0..61e4a13 100644 --- a/dsmr_parser/objects.py +++ b/dsmr_parser/objects.py @@ -50,9 +50,8 @@ class Telegram(object): return [d[1] for d in sorted(self._mbus_devices.items(), key=lambda x: x[0])] def get_mbus_device_by_channel(self, channel_id): - # Check key, because defaultdict would otherwise instantiate an empty MbusDevice - if channel_id in self._mbus_devices: - return self._mbus_devices[channel_id] + # Use .get, because defaultdict would otherwise instantiate an empty MbusDevice + return self._mbus_devices.get(channel_id) def __getattr__(self, name): """ will only get called for undefined attributes """