Remove unused 'cli_config' parameter

Now that `ConfigFileFinder.config_file` attribute is used everywhere and
is constructed from the `--config` CLI option, the now unused
`cli_config` parameters can be safely removed.
This commit is contained in:
Eric N. Vander Weele 2020-01-12 15:33:54 -08:00
parent 77b2506071
commit 1e3bad20dd
8 changed files with 19 additions and 35 deletions

View file

@ -34,13 +34,14 @@ def get_style_guide(**kwargs):
config_finder = config.ConfigFileFinder(
application.program,
prelim_opts.append_config,
config_file=prelim_opts.config,
ignore_config_files=prelim_opts.isolated,
)
application.find_plugins(config_finder, prelim_opts.config)
application.find_plugins(config_finder)
application.register_plugin_options()
application.parse_configuration_and_cli(
config_finder, prelim_opts.config, remaining_args,
config_finder, remaining_args,
)
# We basically want application.initialize to be called but with these
# options set instead before we make our formatter, notifier, internal

View file

@ -131,8 +131,8 @@ class Application(object):
(self.result_count > 0) or self.catastrophic_failure
)
def find_plugins(self, config_finder, config_file):
# type: (config.ConfigFileFinder, Optional[str]) -> None
def find_plugins(self, config_finder):
# type: (config.ConfigFileFinder) -> None
"""Find and load the plugins for this application.
Set the :attr:`check_plugins` and :attr:`formatting_plugins` attributes
@ -140,11 +140,8 @@ class Application(object):
:param config.ConfigFileFinder config_finder:
The finder for finding and reading configuration files.
:param str config_file:
The optional configuraiton file to override all other configuration
files (i.e., the --config option).
"""
local_plugins = config.get_local_plugins(config_finder, config_file)
local_plugins = config.get_local_plugins(config_finder)
sys.path.extend(local_plugins.paths)
@ -167,7 +164,6 @@ class Application(object):
def parse_configuration_and_cli(
self,
config_finder, # type: config.ConfigFileFinder
config_file, # type: Optional[str]
argv, # type: List[str]
):
# type: (...) -> None
@ -175,14 +171,11 @@ class Application(object):
:param config.ConfigFileFinder config_finder:
The finder for finding and reading configuration files.
:param str config_file:
The optional configuraiton file to override all other configuration
files (i.e., the --config option).
:param list argv:
Command-line arguments passed in directly.
"""
self.options, self.args = aggregator.aggregate_options(
self.option_manager, config_finder, config_file, argv,
self.option_manager, config_finder, argv,
)
self.running_against_diff = self.options.diff
@ -327,10 +320,10 @@ class Application(object):
config_file=prelim_opts.config,
ignore_config_files=prelim_opts.isolated,
)
self.find_plugins(config_finder, prelim_opts.config)
self.find_plugins(config_finder)
self.register_plugin_options()
self.parse_configuration_and_cli(
config_finder, prelim_opts.config, remaining_args,
config_finder, remaining_args,
)
self.make_formatter()
self.make_guide()

View file

@ -5,7 +5,7 @@ applies the user-specified command-line configuration on top of it.
"""
import argparse
import logging
from typing import List, Optional, Tuple
from typing import List, Tuple
from flake8.options import config
from flake8.options.manager import OptionManager
@ -16,7 +16,6 @@ LOG = logging.getLogger(__name__)
def aggregate_options(
manager, # type: OptionManager
config_finder, # type: config.ConfigFileFinder
cli_config, # type: Optional[str]
argv, # type: List[str]
): # type: (...) -> Tuple[argparse.Namespace, List[str]]
"""Aggregate and merge CLI and config file options.
@ -25,9 +24,6 @@ def aggregate_options(
The instance of the OptionManager that we're presently using.
:param flake8.options.config.ConfigFileFinder config_finder:
The config file finder to use.
:param str cli_config:
Value of --config when specified at the command-line. Overrides
all other config files.
:param list argv:
The list of remaining command-line argumentsthat were unknown during
preliminary option parsing to pass to ``manager.parse_args``.
@ -46,7 +42,7 @@ def aggregate_options(
)
# Get the parsed config
parsed_config = config_parser.parse(cli_config)
parsed_config = config_parser.parse()
# Extend the default ignore value with the extended default ignore list,
# registered by plugins.

View file

@ -295,16 +295,13 @@ class MergedConfigParser(object):
return config
def parse(self, cli_config=None):
def parse(self):
"""Parse and return the local and user config files.
First this copies over the parsed local configuration and then
iterates over the options in the user configuration and sets them if
they were not set by the local configuration file.
:param str cli_config:
Value of --config when specified at the command-line. Overrides
all other config files.
:returns:
Dictionary of parsed configuration options
:rtype:
@ -329,14 +326,11 @@ class MergedConfigParser(object):
return self.merge_user_and_local_config()
def get_local_plugins(config_finder, cli_config=None):
def get_local_plugins(config_finder):
"""Get local plugins lists from config files.
:param flake8.options.config.ConfigFileFinder config_finder:
The config file finder to use.
:param str cli_config:
Value of --config when specified at the command-line. Overrides
all other config files.
:returns:
LocalPlugins namedtuple containing two lists of plugin strings,
one for extension (checker) plugins and one for report plugins.

View file

@ -35,7 +35,7 @@ def test_aggregate_options_with_config(optmanager):
[],
config_file=CLI_SPECIFIED_CONFIG)
options, args = aggregator.aggregate_options(
optmanager, config_finder, CLI_SPECIFIED_CONFIG, arguments)
optmanager, config_finder, arguments)
assert options.select == ['E11', 'E34', 'E402', 'W', 'F']
assert options.ignore == ['E123', 'W234', 'E111']
@ -50,7 +50,7 @@ def test_aggregate_options_when_isolated(optmanager):
'flake8', [], ignore_config_files=True)
optmanager.extend_default_ignore(['E8'])
options, args = aggregator.aggregate_options(
optmanager, config_finder, None, arguments)
optmanager, config_finder, arguments)
assert options.select == ['E11', 'E34', 'E402', 'W', 'F']
assert sorted(options.ignore) == [

View file

@ -27,7 +27,7 @@ def test_get_local_plugins_uses_cli_config():
config_file_value = 'foo.ini'
config_finder.config_file = config_file_value
config.get_local_plugins(config_finder, cli_config=config_file_value)
config.get_local_plugins(config_finder)
config_finder.cli_config.assert_called_once_with(config_file_value)

View file

@ -31,10 +31,10 @@ def test_get_style_guide():
application.assert_called_once_with()
mockedapp.parse_preliminary_options.assert_called_once_with([])
mockedapp.find_plugins.assert_called_once_with(config_finder, None)
mockedapp.find_plugins.assert_called_once_with(config_finder)
mockedapp.register_plugin_options.assert_called_once_with()
mockedapp.parse_configuration_and_cli.assert_called_once_with(
config_finder, None, [])
config_finder, [])
mockedapp.make_formatter.assert_called_once_with()
mockedapp.make_guide.assert_called_once_with()
mockedapp.make_file_checker_manager.assert_called_once_with()

View file

@ -161,7 +161,7 @@ def test_parse_uses_cli_config(optmanager):
config_finder.ignore_config_files = False
parser = config.MergedConfigParser(optmanager, config_finder)
parser.parse(cli_config=config_file_value)
parser.parse()
config_finder.cli_config.assert_called_once_with(config_file_value)