diff options
| author | Eric N. Vander Weele <ericvw@gmail.com> | 2020-01-01 23:38:51 -0500 |
|---|---|---|
| committer | Eric N. Vander Weele <ericvw@gmail.com> | 2020-01-06 22:23:12 -0500 |
| commit | 1a4060cd5f5d3d2f638d01f563e3c42aeb89a135 (patch) | |
| tree | 5c5fcf83437bef3a5ffed54f86516693a8ccae99 /src | |
| parent | 20906d43046096c31dfcd9b8bc536dbd21f043ef (diff) | |
| download | flake8-1a4060cd5f5d3d2f638d01f563e3c42aeb89a135.tar.gz | |
config: Change ConfigFileFinder._read_config() to accept variadic args
This simplifies `._read_config()` by removing a conditional branch in
the situation where it is called with one file to process. Now the
contract accepts any number of arguments of the same type.
Where callers invoke `._read_config()` with a `Sequence`, the call site
has been changed to unpack arguments (i.e., `*`).
The tests in `test_merged_config_parser.py` needed to return a string
for the user configuration path instead of an empty list since
`ConfigFileFinder.user_config_file()` returns a string.
Diffstat (limited to 'src')
| -rw-r--r-- | src/flake8/options/config.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/flake8/options/config.py b/src/flake8/options/config.py index 9aebcba..e1952be 100644 --- a/src/flake8/options/config.py +++ b/src/flake8/options/config.py @@ -4,7 +4,7 @@ import configparser import logging import os.path import sys -from typing import Dict, List, Sequence, Tuple, Union +from typing import Dict, List, Tuple from flake8 import utils @@ -55,11 +55,9 @@ class ConfigFileFinder(object): # fmt: on @staticmethod - def _read_config(files): - # type: (Union[Sequence[str], str]) -> Tuple[configparser.RawConfigParser, List[str]] # noqa: E501 + def _read_config(*files): + # type: (*str) -> Tuple[configparser.RawConfigParser, List[str]] config = configparser.RawConfigParser() - if isinstance(files, (str, type(u""))): - files = [files] found_files = [] for filename in files: @@ -129,7 +127,9 @@ class ConfigFileFinder(object): Return (config, found_config_files) tuple. """ if self._local_configs is None: - config, found_files = self._read_config(self.local_config_files()) + config, found_files = self._read_config( + *self.local_config_files() + ) if found_files: LOG.debug("Found local configuration files: %s", found_files) self._local_configs = config |
