config: if option value was previously set, ignore from options value

This commit is contained in:
Benjamin Renard 2023-01-10 10:50:48 +01:00
parent 5fefc1ed84
commit 56162452ac

View file

@ -43,6 +43,7 @@ class BaseOption: # pylint: disable=too-many-instance-attributes
self.arg = arg self.arg = arg
self.short_arg = short_arg self.short_arg = short_arg
self.arg_help = arg_help if arg_help else comment self.arg_help = arg_help if arg_help else comment
self._set = False
@property @property
def _isset_in_options(self): def _isset_in_options(self):
@ -93,7 +94,7 @@ class BaseOption: # pylint: disable=too-many-instance-attributes
def get(self): def get(self):
""" Get option value from options, config or default """ """ 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 return self._from_options
if self._isset_in_config_file: if self._isset_in_config_file:
return self._from_config 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) self.section.name, self.name, self.to_config(value)
) )
if self.config.options and not self.no_arg: self._set = True
setattr(self.config.options, self.parser_dest, value)
@property @property
def parser_action(self): def parser_action(self):