diff options
Diffstat (limited to 'logilab/common/configuration.py')
-rw-r--r-- | logilab/common/configuration.py | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/logilab/common/configuration.py b/logilab/common/configuration.py index 2429297..1e52bca 100644 --- a/logilab/common/configuration.py +++ b/logilab/common/configuration.py @@ -165,8 +165,7 @@ _ValueType = Union[List[str], Tuple[str, ...], str] def choice_validator(optdict: Dict[str, Any], name: str, value: str) -> str: - """validate and return a converted value for option of type 'choice' - """ + """validate and return a converted value for option of type 'choice'""" if value not in optdict["choices"]: msg = "option %s: invalid value: %r, should be in %s" raise optik_ext.OptionValueError(msg % (name, value, optdict["choices"])) @@ -174,8 +173,7 @@ def choice_validator(optdict: Dict[str, Any], name: str, value: str) -> str: def multiple_choice_validator(optdict: Dict[str, Any], name: str, value: _ValueType) -> _ValueType: - """validate and return a converted value for option of type 'choice' - """ + """validate and return a converted value for option of type 'choice'""" choices = optdict["choices"] values = optik_ext.check_csv(None, name, value) for value in values: @@ -186,22 +184,19 @@ def multiple_choice_validator(optdict: Dict[str, Any], name: str, value: _ValueT def csv_validator(optdict: Dict[str, Any], name: str, value: _ValueType) -> _ValueType: - """validate and return a converted value for option of type 'csv' - """ + """validate and return a converted value for option of type 'csv'""" return optik_ext.check_csv(None, name, value) def yn_validator(optdict: Dict[str, Any], name: str, value: Union[bool, str]) -> bool: - """validate and return a converted value for option of type 'yn' - """ + """validate and return a converted value for option of type 'yn'""" return optik_ext.check_yn(None, name, value) def named_validator( optdict: Dict[str, Any], name: str, value: Union[Dict[str, str], str] ) -> Dict[str, str]: - """validate and return a converted value for option of type 'named' - """ + """validate and return a converted value for option of type 'named'""" return optik_ext.check_named(None, name, value) @@ -537,9 +532,7 @@ class OptionsManagerMixIn(object): # mypy: Need type annotation for 'option' # you can't type variable of a list comprehension, right? non_group_spec_options: List = [ - option - for option in provider.options # type: ignore - if "group" not in option[1] + option for option in provider.options if "group" not in option[1] # type: ignore ] # type: ignore groups = getattr(provider, "option_groups", ()) @@ -569,8 +562,7 @@ class OptionsManagerMixIn(object): options: Union[List[Tuple[str, Dict[str, Any]]], List[Tuple[str, Dict[str, str]]]], provider: "ConfigurationMixIn", ) -> None: - """add an option group including the listed options - """ + """add an option group including the listed options""" assert options # add option group to the command line parser if group_name in self._mygroups: @@ -794,8 +786,7 @@ class OptionsManagerMixIn(object): continue def load_configuration(self, **kwargs: Any) -> None: - """override configuration according to given parameters - """ + """override configuration according to given parameters""" for opt, opt_value in kwargs.items(): opt = opt.replace("_", "-") provider = self._all_options[opt] @@ -935,8 +926,7 @@ class OptionsProviderMixIn(object): return default def option_attrname(self, opt, optdict=None): - """get the config attribute corresponding to opt - """ + """get the config attribute corresponding to opt""" if optdict is None: optdict = self.get_option_def(opt) return optdict.get("dest", opt.replace("-", "_")) @@ -950,8 +940,7 @@ class OptionsProviderMixIn(object): return getattr(self.config, self.option_attrname(opt), None) def set_option(self, opt, value, action=None, optdict=None): - """method called to set an option (registered in the options list) - """ + """method called to set an option (registered in the options list)""" if optdict is None: optdict = self.get_option_def(opt) if value is not None: |