summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric N. Vander Weele <ericvw@gmail.com>2020-01-12 14:41:20 -0800
committerEric N. Vander Weele <ericvw@gmail.com>2020-01-12 23:19:26 -0500
commit153032f778d609b206cbfdb56ddf27e6f46925c4 (patch)
treebd6daf52e4e2b0b67d20c3f484bc63ee17072bff /src
parent24c2693979612f1178c444bc991beaed58933a20 (diff)
downloadflake8-153032f778d609b206cbfdb56ddf27e6f46925c4.tar.gz
config: Add 'config_file' parameter to ConfigFileFinder
The `--config` flag is passed into `MergedConfigParser.parse()` and the module-level function `config.get_local_plugins()`. Since both of these places utilize the `ConfigFileFinder` object and the configuration file override pertains to how configuration behaves, this incremental change directly associates the `ConfigFileFinder` and the configuration file override.
Diffstat (limited to 'src')
-rw-r--r--src/flake8/main/application.py1
-rw-r--r--src/flake8/options/config.py15
2 files changed, 13 insertions, 3 deletions
diff --git a/src/flake8/main/application.py b/src/flake8/main/application.py
index 6a59e1a..b96a605 100644
--- a/src/flake8/main/application.py
+++ b/src/flake8/main/application.py
@@ -324,6 +324,7 @@ class Application(object):
config_finder = config.ConfigFileFinder(
self.program,
prelim_opts.append_config,
+ config_file=prelim_opts.config,
ignore_config_files=prelim_opts.isolated,
)
self.find_plugins(config_finder, prelim_opts.config)
diff --git a/src/flake8/options/config.py b/src/flake8/options/config.py
index dab16c4..76a81cf 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, Tuple
+from typing import Dict, List, Optional, Tuple
from flake8 import utils
@@ -17,15 +17,21 @@ class ConfigFileFinder(object):
"""Encapsulate the logic for finding and reading config files."""
def __init__(
- self, program_name, extra_config_files, ignore_config_files=False
+ self,
+ program_name,
+ extra_config_files,
+ config_file=None,
+ ignore_config_files=False,
):
- # type: (str, List[str], bool) -> None
+ # type: (str, List[str], Optional[str], bool) -> None
"""Initialize object to find config files.
:param str program_name:
Name of the current program (e.g., flake8).
:param list extra_config_files:
Extra configuration files specified by the user to read.
+ :param str config_file:
+ Configuration file override to only read configuraiton from.
:param bool ignore_config_files:
Determine whether to ignore configuration files or not.
"""
@@ -33,6 +39,9 @@ class ConfigFileFinder(object):
extra_config_files = extra_config_files or []
self.extra_config_files = utils.normalize_paths(extra_config_files)
+ # The value of --config from the CLI.
+ self.config_file = config_file
+
# The value of --isolated from the CLI.
self.ignore_config_files = ignore_config_files