Remove unused 'isolated' parameter

Now that `ConfigFileFinder.ignore_config_files` attribute is used
everywhere and is constructed from the `--isolated` CLI option, the now
unused `isolated` parameters can be safely removed.
This commit is contained in:
Eric N. Vander Weele 2020-01-07 13:14:34 -05:00
parent 3d546d448a
commit c918e72496
8 changed files with 22 additions and 48 deletions

View file

@ -32,18 +32,15 @@ def get_style_guide(**kwargs):
prelim_opts, remaining_args = application.parse_preliminary_options([]) prelim_opts, remaining_args = application.parse_preliminary_options([])
flake8.configure_logging(prelim_opts.verbose, prelim_opts.output_file) flake8.configure_logging(prelim_opts.verbose, prelim_opts.output_file)
config_finder = config.ConfigFileFinder( config_finder = config.ConfigFileFinder(
application.program, prelim_opts.append_config application.program,
prelim_opts.append_config,
ignore_config_files=prelim_opts.isolated,
) )
application.find_plugins( application.find_plugins(config_finder, prelim_opts.config)
config_finder, prelim_opts.config, prelim_opts.isolated
)
application.register_plugin_options() application.register_plugin_options()
application.parse_configuration_and_cli( application.parse_configuration_and_cli(
config_finder, config_finder, prelim_opts.config, remaining_args,
prelim_opts.config,
prelim_opts.isolated,
remaining_args,
) )
# We basically want application.initialize to be called but with these # We basically want application.initialize to be called but with these
# options set instead before we make our formatter, notifier, internal # 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 (self.result_count > 0) or self.catastrophic_failure
) )
def find_plugins(self, config_finder, config_file, ignore_config_files): def find_plugins(self, config_finder, config_file):
# type: (config.ConfigFileFinder, Optional[str], bool) -> None # type: (config.ConfigFileFinder, Optional[str]) -> None
"""Find and load the plugins for this application. """Find and load the plugins for this application.
Set the :attr:`check_plugins` and :attr:`formatting_plugins` attributes Set the :attr:`check_plugins` and :attr:`formatting_plugins` attributes
@ -147,9 +147,7 @@ class Application(object):
Determine whether to parse configuration files or not. (i.e., the Determine whether to parse configuration files or not. (i.e., the
--isolated option). --isolated option).
""" """
local_plugins = config.get_local_plugins( local_plugins = config.get_local_plugins(config_finder, config_file)
config_finder, config_file, ignore_config_files
)
sys.path.extend(local_plugins.paths) sys.path.extend(local_plugins.paths)
@ -173,7 +171,6 @@ class Application(object):
self, self,
config_finder, # type: config.ConfigFileFinder config_finder, # type: config.ConfigFileFinder
config_file, # type: Optional[str] config_file, # type: Optional[str]
ignore_config_files, # type: bool
argv, # type: List[str] argv, # type: List[str]
): ):
# type: (...) -> None # type: (...) -> None
@ -184,18 +181,11 @@ class Application(object):
:param str config_file: :param str config_file:
The optional configuraiton file to override all other configuration The optional configuraiton file to override all other configuration
files (i.e., the --config option). files (i.e., the --config option).
:param bool ignore_config_files:
Determine whether to parse configuration files or not. (i.e., the
--isolated option).
:param list argv: :param list argv:
Command-line arguments passed in directly. Command-line arguments passed in directly.
""" """
self.options, self.args = aggregator.aggregate_options( self.options, self.args = aggregator.aggregate_options(
self.option_manager, self.option_manager, config_finder, config_file, argv,
config_finder,
config_file,
ignore_config_files,
argv,
) )
self.running_against_diff = self.options.diff self.running_against_diff = self.options.diff
@ -339,15 +329,10 @@ class Application(object):
prelim_opts.append_config, prelim_opts.append_config,
ignore_config_files=prelim_opts.isolated, ignore_config_files=prelim_opts.isolated,
) )
self.find_plugins( self.find_plugins(config_finder, prelim_opts.config)
config_finder, prelim_opts.config, prelim_opts.isolated
)
self.register_plugin_options() self.register_plugin_options()
self.parse_configuration_and_cli( self.parse_configuration_and_cli(
config_finder, config_finder, prelim_opts.config, remaining_args,
prelim_opts.config,
prelim_opts.isolated,
remaining_args,
) )
self.make_formatter() self.make_formatter()
self.make_guide() self.make_guide()

View file

@ -17,7 +17,6 @@ def aggregate_options(
manager, # type: OptionManager manager, # type: OptionManager
config_finder, # type: config.ConfigFileFinder config_finder, # type: config.ConfigFileFinder
cli_config, # type: Optional[str] cli_config, # type: Optional[str]
isolated, # type: bool
argv, # type: List[str] argv, # type: List[str]
): # type: (...) -> Tuple[argparse.Namespace, List[str]] ): # type: (...) -> Tuple[argparse.Namespace, List[str]]
"""Aggregate and merge CLI and config file options. """Aggregate and merge CLI and config file options.
@ -29,9 +28,6 @@ def aggregate_options(
:param str cli_config: :param str cli_config:
Value of --config when specified at the command-line. Overrides Value of --config when specified at the command-line. Overrides
all other config files. all other config files.
:param bool isolated:
Determines if we should parse configuration files at all or not.
If running in isolated mode, we ignore all configuration files
:param list argv: :param list argv:
The list of remaining command-line argumentsthat were unknown during The list of remaining command-line argumentsthat were unknown during
preliminary option parsing to pass to ``manager.parse_args``. preliminary option parsing to pass to ``manager.parse_args``.
@ -50,7 +46,7 @@ def aggregate_options(
) )
# Get the parsed config # Get the parsed config
parsed_config = config_parser.parse(cli_config, isolated) parsed_config = config_parser.parse(cli_config)
# Extend the default ignore value with the extended default ignore list, # Extend the default ignore value with the extended default ignore list,
# registered by plugins. # registered by plugins.

View file

@ -289,7 +289,7 @@ class MergedConfigParser(object):
return config return config
def parse(self, cli_config=None, isolated=False): def parse(self, cli_config=None):
"""Parse and return the local and user config files. """Parse and return the local and user config files.
First this copies over the parsed local configuration and then First this copies over the parsed local configuration and then
@ -299,9 +299,6 @@ class MergedConfigParser(object):
:param str cli_config: :param str cli_config:
Value of --config when specified at the command-line. Overrides Value of --config when specified at the command-line. Overrides
all other config files. all other config files.
:param bool isolated:
Determines if we should parse configuration files at all or not.
If running in isolated mode, we ignore all configuration files
:returns: :returns:
Dictionary of parsed configuration options Dictionary of parsed configuration options
:rtype: :rtype:
@ -326,7 +323,7 @@ class MergedConfigParser(object):
return self.merge_user_and_local_config() return self.merge_user_and_local_config()
def get_local_plugins(config_finder, cli_config=None, isolated=False): def get_local_plugins(config_finder, cli_config=None):
"""Get local plugins lists from config files. """Get local plugins lists from config files.
:param flake8.options.config.ConfigFileFinder config_finder: :param flake8.options.config.ConfigFileFinder config_finder:
@ -334,9 +331,6 @@ def get_local_plugins(config_finder, cli_config=None, isolated=False):
:param str cli_config: :param str cli_config:
Value of --config when specified at the command-line. Overrides Value of --config when specified at the command-line. Overrides
all other config files. all other config files.
:param bool isolated:
Determines if we should parse configuration files at all or not.
If running in isolated mode, we ignore all configuration files
:returns: :returns:
LocalPlugins namedtuple containing two lists of plugin strings, LocalPlugins namedtuple containing two lists of plugin strings,
one for extension (checker) plugins and one for report plugins. one for extension (checker) plugins and one for report plugins.

View file

@ -32,7 +32,7 @@ def test_aggregate_options_with_config(optmanager):
'E11,E34,E402,W,F', '--exclude', 'tests/*'] 'E11,E34,E402,W,F', '--exclude', 'tests/*']
config_finder = config.ConfigFileFinder('flake8', []) config_finder = config.ConfigFileFinder('flake8', [])
options, args = aggregator.aggregate_options( options, args = aggregator.aggregate_options(
optmanager, config_finder, CLI_SPECIFIED_CONFIG, False, arguments) optmanager, config_finder, CLI_SPECIFIED_CONFIG, arguments)
assert options.select == ['E11', 'E34', 'E402', 'W', 'F'] assert options.select == ['E11', 'E34', 'E402', 'W', 'F']
assert options.ignore == ['E123', 'W234', 'E111'] assert options.ignore == ['E123', 'W234', 'E111']
@ -47,7 +47,7 @@ def test_aggregate_options_when_isolated(optmanager):
'flake8', [], ignore_config_files=True) 'flake8', [], ignore_config_files=True)
optmanager.extend_default_ignore(['E8']) optmanager.extend_default_ignore(['E8'])
options, args = aggregator.aggregate_options( options, args = aggregator.aggregate_options(
optmanager, config_finder, None, True, arguments) optmanager, config_finder, None, arguments)
assert options.select == ['E11', 'E34', 'E402', 'W', 'F'] assert options.select == ['E11', 'E34', 'E402', 'W', 'F']
assert sorted(options.ignore) == [ assert sorted(options.ignore) == [

View file

@ -7,8 +7,9 @@ from flake8.options import config
def test_get_local_plugins_respects_isolated(): def test_get_local_plugins_respects_isolated():
"""Verify behaviour of get_local_plugins with isolated=True.""" """Verify behaviour of get_local_plugins with isolated=True."""
config_finder = mock.MagicMock() config_finder = mock.MagicMock()
config_finder.ignore_config_files = True
local_plugins = config.get_local_plugins(config_finder, isolated=True) local_plugins = config.get_local_plugins(config_finder)
assert local_plugins.extension == [] assert local_plugins.extension == []
assert local_plugins.report == [] assert local_plugins.report == []

View file

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

View file

@ -145,9 +145,10 @@ def test_merge_user_and_local_config(optmanager, config_finder):
def test_parse_isolates_config(optmanager): def test_parse_isolates_config(optmanager):
"""Verify behaviour of the parse method with isolated=True.""" """Verify behaviour of the parse method with isolated=True."""
config_finder = mock.MagicMock() config_finder = mock.MagicMock()
config_finder.ignore_config_files = True
parser = config.MergedConfigParser(optmanager, config_finder) parser = config.MergedConfigParser(optmanager, config_finder)
assert parser.parse(isolated=True) == {} assert parser.parse() == {}
assert config_finder.local_configs.called is False assert config_finder.local_configs.called is False
assert config_finder.user_config.called is False assert config_finder.user_config.called is False