From dda20d4e308af1afceb58839e93ccc4210c9f3fc Mon Sep 17 00:00:00 2001 From: David Garcia Date: Tue, 22 Sep 2020 11:36:48 +0200 Subject: [PATCH] Improve Config.get() function The .get is a bit confusing because apparently has the same behaviour as dict.get(), which returns None when the key doesn't exist. But that's not the case, because Config.get in this case is doing dict["key"], which returns a KeyError when the key does not exist Change-Id: Ief82eb1ae2e2fea60b8be60cae8610bf8605fb6f Signed-off-by: David Garcia --- osm_mon/core/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osm_mon/core/config.py b/osm_mon/core/config.py index c4c3972..cd99ffc 100644 --- a/osm_mon/core/config.py +++ b/osm_mon/core/config.py @@ -48,7 +48,7 @@ class Config: def get(self, section, field=None): if not field: return self.conf[section] - return self.conf[section][field] + return self.conf[section].get(field) def set(self, section, field, value): if section not in self.conf: -- 2.17.1