diff --git a/config/__init__.py b/config/__init__.py index 1fa45c3f..fa9a5293 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -319,17 +319,17 @@ class AbstractConfig(abc.ABC): warnings.warn(DeprecationWarning('get is Deprecated. use the specific getter for your type')) logger.debug('Attempt to use Deprecated get() method\n' + ''.join(traceback.format_stack())) - if (l := self._suppress_call(self.get_list, ValueError, key, default=None)) is not None: - return l + if (a_list := self._suppress_call(self.get_list, ValueError, key, default=None)) is not None: + return a_list - elif (s := self._suppress_call(self.get_str, ValueError, key, default=None)) is not None: - return s + elif (a_str := self._suppress_call(self.get_str, ValueError, key, default=None)) is not None: + return a_str - elif (b := self._suppress_call(self.get_bool, ValueError, key, default=None)) is not None: - return b + elif (a_bool := self._suppress_call(self.get_bool, ValueError, key, default=None)) is not None: + return a_bool - elif (i := self._suppress_call(self.get_int, ValueError, key, default=None)) is not None: - return i + elif (an_int := self._suppress_call(self.get_int, ValueError, key, default=None)) is not None: + return an_int return default # type: ignore diff --git a/tests/config/test_config.py b/tests/config/test_config.py index 4f72d437..b6637623 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -41,7 +41,7 @@ def _fuzz_list(length: int) -> List[str]: _fuzz_generators = { # Type annotating this would be a nightmare. int: lambda i: random.randint(min(0, i), max(0, i)), # This doesn't cover unicode, or random bytes. Use them at your own peril - str: lambda l: "".join(random.choice(string.ascii_letters + string.digits + '\r\n') for _ in range(l)), + str: lambda s: "".join(random.choice(string.ascii_letters + string.digits + '\r\n') for _ in range(s)), bool: lambda _: bool(random.choice((True, False))), list: _fuzz_list, }