diff options
Diffstat (limited to 'logilab/common/configuration.py')
-rw-r--r-- | logilab/common/configuration.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/logilab/common/configuration.py b/logilab/common/configuration.py index 4c83030..fac0121 100644 --- a/logilab/common/configuration.py +++ b/logilab/common/configuration.py @@ -126,8 +126,7 @@ from os.path import exists, expanduser from optparse import OptionGroup from copy import copy from _io import StringIO, TextIOWrapper -from mypy_extensions import NoReturn -from typing import Any, Optional, Union, Dict, List, Tuple, Iterator, Callable, Sequence +from typing import Any, Optional, Union, Dict, List, Tuple, Iterator, Callable from warnings import warn import configparser as cp @@ -168,7 +167,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' """ - if not value in optdict["choices"]: + 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"])) return value @@ -180,7 +179,7 @@ def multiple_choice_validator(optdict: Dict[str, Any], name: str, value: _ValueT choices = optdict["choices"] values = optik_ext.check_csv(None, name, value) for value in values: - if not value in choices: + if value not in choices: msg = "option %s: invalid value: %r, should be in %s" raise optik_ext.OptionValueError(msg % (name, value, choices)) return values @@ -269,7 +268,7 @@ def _call_validator( return VALIDATORS[opttype](value) except optik_ext.OptionValueError: raise - except: + except Exception: raise optik_ext.OptionValueError( "%s value (%r) should be of type %s" % (option, value, opttype) ) @@ -638,7 +637,7 @@ class OptionsManagerMixIn(object): del optdict["short"] # cleanup option definition dict before giving it to optik for key in list(optdict.keys()): - if not key in self._optik_option_attrs: + if key not in self._optik_option_attrs: optdict.pop(key) return args, optdict @@ -682,7 +681,7 @@ class OptionsManagerMixIn(object): options = [(n, d, v) for (n, d, v) in options if d.get("type") is not None] if not options: continue - if not section in sections: + if section not in sections: sections.append(section) alloptions = options_by_section.setdefault(section, []) alloptions += options @@ -773,7 +772,7 @@ class OptionsManagerMixIn(object): for section, option, optdict in provider.all_options(): if onlysection is not None and section != onlysection: continue - if not "type" in optdict: + if "type" not in optdict: # ignore action without type (callback, store_true...) continue provider.input_option(option, optdict, inputlevel) @@ -1079,7 +1078,7 @@ class ConfigurationMixIn(OptionsManagerMixIn, OptionsProviderMixIn): gdef = (optdict["group"].upper(), "") except KeyError: continue - if not gdef in self.option_groups: + if gdef not in self.option_groups: self.option_groups.append(gdef) self.register_options_provider(self, own_group=False) @@ -1225,7 +1224,7 @@ def read_old_config(newconfig, changes, configfile): newconfig[optname] = newvalue done.add(optname) for optname, optdef in newconfig.options: - if optdef.get("type") and not optname in done: + if optdef.get("type") and optname not in done: newconfig.set_option(optname, oldconfig[optname], optdict=optdef) |