From 56162452ac49763d6170c479c90e3244d8e79d93 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 10 Jan 2023 10:50:48 +0100 Subject: [PATCH] config: if option value was previously set, ignore from options value --- mylib/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mylib/config.py b/mylib/config.py index dbadc31..688c007 100644 --- a/mylib/config.py +++ b/mylib/config.py @@ -43,6 +43,7 @@ class BaseOption: # pylint: disable=too-many-instance-attributes self.arg = arg self.short_arg = short_arg self.arg_help = arg_help if arg_help else comment + self._set = False @property def _isset_in_options(self): @@ -93,7 +94,7 @@ class BaseOption: # pylint: disable=too-many-instance-attributes def get(self): """ Get option value from options, config or default """ - if self._isset_in_options: + if self._isset_in_options and not self._set: return self._from_options if self._isset_in_config_file: return self._from_config @@ -118,8 +119,7 @@ class BaseOption: # pylint: disable=too-many-instance-attributes self.section.name, self.name, self.to_config(value) ) - if self.config.options and not self.no_arg: - setattr(self.config.options, self.parser_dest, value) + self._set = True @property def parser_action(self):