mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-14 00:14:46 +00:00
config: Switch code paths to use 'ConfigFileFinder.ignore_config_files'
Now that the `ConfigFileFinder` has the `.ignore_config_files` attribute, switch the relevant code paths to utilize this public attribute. Tests have been updated to either construct `ConfigFileFinder` or mock the object appropriately.
This commit is contained in:
parent
a5c17c1a19
commit
3d546d448a
4 changed files with 6 additions and 3 deletions
|
|
@ -307,7 +307,7 @@ class MergedConfigParser(object):
|
||||||
:rtype:
|
:rtype:
|
||||||
dict
|
dict
|
||||||
"""
|
"""
|
||||||
if isolated:
|
if self.config_finder.ignore_config_files:
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"Refusing to parse configuration files due to user-"
|
"Refusing to parse configuration files due to user-"
|
||||||
"requested isolation"
|
"requested isolation"
|
||||||
|
|
@ -344,7 +344,7 @@ def get_local_plugins(config_finder, cli_config=None, isolated=False):
|
||||||
flake8.options.config.LocalPlugins
|
flake8.options.config.LocalPlugins
|
||||||
"""
|
"""
|
||||||
local_plugins = LocalPlugins(extension=[], report=[], paths=[])
|
local_plugins = LocalPlugins(extension=[], report=[], paths=[])
|
||||||
if isolated:
|
if config_finder.ignore_config_files:
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"Refusing to look for local plugins in configuration"
|
"Refusing to look for local plugins in configuration"
|
||||||
"files due to user-requested isolation"
|
"files due to user-requested isolation"
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,8 @@ def test_aggregate_options_when_isolated(optmanager):
|
||||||
"""Verify we aggregate options and config values appropriately."""
|
"""Verify we aggregate options and config values appropriately."""
|
||||||
arguments = ['flake8', '--select', 'E11,E34,E402,W,F',
|
arguments = ['flake8', '--select', 'E11,E34,E402,W,F',
|
||||||
'--exclude', 'tests/*']
|
'--exclude', 'tests/*']
|
||||||
config_finder = config.ConfigFileFinder('flake8', [])
|
config_finder = config.ConfigFileFinder(
|
||||||
|
'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, True, arguments)
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ def test_get_local_plugins_uses_cli_config():
|
||||||
config_obj = mock.Mock()
|
config_obj = mock.Mock()
|
||||||
config_finder = mock.MagicMock()
|
config_finder = mock.MagicMock()
|
||||||
config_finder.cli_config.return_value = config_obj
|
config_finder.cli_config.return_value = config_obj
|
||||||
|
config_finder.ignore_config_files = False
|
||||||
config_obj.get.return_value = ''
|
config_obj.get.return_value = ''
|
||||||
|
|
||||||
config.get_local_plugins(config_finder, cli_config='foo.ini')
|
config.get_local_plugins(config_finder, cli_config='foo.ini')
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,7 @@ def test_parse_isolates_config(optmanager):
|
||||||
def test_parse_uses_cli_config(optmanager):
|
def test_parse_uses_cli_config(optmanager):
|
||||||
"""Verify behaviour of the parse method with a specified config."""
|
"""Verify behaviour of the parse method with a specified config."""
|
||||||
config_finder = mock.MagicMock()
|
config_finder = mock.MagicMock()
|
||||||
|
config_finder.ignore_config_files = False
|
||||||
parser = config.MergedConfigParser(optmanager, config_finder)
|
parser = config.MergedConfigParser(optmanager, config_finder)
|
||||||
|
|
||||||
parser.parse(cli_config='foo.ini')
|
parser.parse(cli_config='foo.ini')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue