mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-05 04:36:52 +00:00
Drop support for Home and XDG config files
This has been a huge support burden for us. I seriously considered doing this in 3.0 but caved to a vocal minority and the desire to keep as much backwards compatibility as possible. At this point, however, I'm done witnessing the abuse Anthony has to suffer over this and I'm done with the undue hostility that people who don't bother to read the docs display. Hopefully, this eases that a bit.
This commit is contained in:
parent
0b1c790443
commit
807904aebc
6 changed files with 49 additions and 157 deletions
|
|
@ -1,4 +1,4 @@
|
|||
"""Unit tests for flake8.options.config.MergedConfigParser."""
|
||||
"""Unit tests for flake8.options.config.ConfigParser."""
|
||||
import os
|
||||
from unittest import mock
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ def test_parse_cli_config(optmanager, config_finder):
|
|||
"--ignore", parse_from_config=True, comma_separated_list=True
|
||||
)
|
||||
optmanager.add_option("--quiet", parse_from_config=True, action="count")
|
||||
parser = config.MergedConfigParser(optmanager, config_finder)
|
||||
parser = config.ConfigParser(optmanager, config_finder)
|
||||
|
||||
config_file = "tests/fixtures/config_files/cli-specified.ini"
|
||||
parsed_config = parser.parse_cli_config(config_file)
|
||||
|
|
@ -61,41 +61,11 @@ def test_is_configured_by(
|
|||
):
|
||||
"""Verify the behaviour of the is_configured_by method."""
|
||||
parsed_config, _ = config.ConfigFileFinder._read_config(filename)
|
||||
parser = config.MergedConfigParser(optmanager, config_finder)
|
||||
parser = config.ConfigParser(optmanager, config_finder)
|
||||
|
||||
assert parser.is_configured_by(parsed_config) is is_configured_by
|
||||
|
||||
|
||||
def test_parse_user_config(optmanager, config_finder):
|
||||
"""Verify parsing of user config files."""
|
||||
optmanager.add_option(
|
||||
"--exclude",
|
||||
parse_from_config=True,
|
||||
comma_separated_list=True,
|
||||
normalize_paths=True,
|
||||
)
|
||||
optmanager.add_option(
|
||||
"--ignore", parse_from_config=True, comma_separated_list=True
|
||||
)
|
||||
optmanager.add_option("--quiet", parse_from_config=True, action="count")
|
||||
parser = config.MergedConfigParser(optmanager, config_finder)
|
||||
|
||||
config_finder.user_config_file = (
|
||||
"tests/fixtures/config_files/" "cli-specified.ini"
|
||||
)
|
||||
parsed_config = parser.parse_user_config()
|
||||
|
||||
assert parsed_config == {
|
||||
"ignore": ["E123", "W234", "E111"],
|
||||
"exclude": [
|
||||
os.path.abspath("foo/"),
|
||||
os.path.abspath("bar/"),
|
||||
os.path.abspath("bogus/"),
|
||||
],
|
||||
"quiet": 1,
|
||||
}
|
||||
|
||||
|
||||
def test_parse_local_config(optmanager, config_finder):
|
||||
"""Verify parsing of local config files."""
|
||||
optmanager.add_option(
|
||||
|
|
@ -108,7 +78,7 @@ def test_parse_local_config(optmanager, config_finder):
|
|||
"--ignore", parse_from_config=True, comma_separated_list=True
|
||||
)
|
||||
optmanager.add_option("--quiet", parse_from_config=True, action="count")
|
||||
parser = config.MergedConfigParser(optmanager, config_finder)
|
||||
parser = config.ConfigParser(optmanager, config_finder)
|
||||
|
||||
with mock.patch.object(config_finder, "local_config_files") as localcfs:
|
||||
localcfs.return_value = [
|
||||
|
|
@ -127,47 +97,14 @@ def test_parse_local_config(optmanager, config_finder):
|
|||
}
|
||||
|
||||
|
||||
def test_merge_user_and_local_config(optmanager, config_finder):
|
||||
"""Verify merging of parsed user and local config files."""
|
||||
optmanager.add_option(
|
||||
"--exclude",
|
||||
parse_from_config=True,
|
||||
comma_separated_list=True,
|
||||
normalize_paths=True,
|
||||
)
|
||||
optmanager.add_option(
|
||||
"--ignore", parse_from_config=True, comma_separated_list=True
|
||||
)
|
||||
optmanager.add_option(
|
||||
"--select", parse_from_config=True, comma_separated_list=True
|
||||
)
|
||||
parser = config.MergedConfigParser(optmanager, config_finder)
|
||||
|
||||
with mock.patch.object(config_finder, "local_config_files") as localcfs:
|
||||
localcfs.return_value = [
|
||||
"tests/fixtures/config_files/local-config.ini"
|
||||
]
|
||||
config_finder.user_config_file = (
|
||||
"tests/fixtures/config_files/" "user-config.ini"
|
||||
)
|
||||
parsed_config = parser.merge_user_and_local_config()
|
||||
|
||||
assert parsed_config == {
|
||||
"exclude": [os.path.abspath("docs/")],
|
||||
"ignore": ["D203"],
|
||||
"select": ["E", "W", "F"],
|
||||
}
|
||||
|
||||
|
||||
def test_parse_isolates_config(optmanager):
|
||||
"""Verify behaviour of the parse method with isolated=True."""
|
||||
config_finder = mock.MagicMock()
|
||||
config_finder.ignore_config_files = True
|
||||
parser = config.MergedConfigParser(optmanager, config_finder)
|
||||
parser = config.ConfigParser(optmanager, config_finder)
|
||||
|
||||
assert parser.parse() == {}
|
||||
assert config_finder.local_configs.called is False
|
||||
assert config_finder.user_config.called is False
|
||||
|
||||
|
||||
def test_parse_uses_cli_config(optmanager):
|
||||
|
|
@ -176,7 +113,7 @@ def test_parse_uses_cli_config(optmanager):
|
|||
config_finder = mock.MagicMock()
|
||||
config_finder.config_file = config_file_value
|
||||
config_finder.ignore_config_files = False
|
||||
parser = config.MergedConfigParser(optmanager, config_finder)
|
||||
parser = config.ConfigParser(optmanager, config_finder)
|
||||
|
||||
parser.parse()
|
||||
config_finder.cli_config.assert_called_once_with(config_file_value)
|
||||
|
|
@ -206,13 +143,11 @@ def test_parsed_configs_are_equivalent(
|
|||
optmanager.add_option(
|
||||
"--ignore", parse_from_config=True, comma_separated_list=True
|
||||
)
|
||||
parser = config.MergedConfigParser(optmanager, config_finder)
|
||||
parser = config.ConfigParser(optmanager, config_finder)
|
||||
|
||||
with mock.patch.object(config_finder, "local_config_files") as localcfs:
|
||||
localcfs.return_value = [config_fixture_path]
|
||||
with mock.patch.object(config_finder, "user_config_file") as usercf:
|
||||
usercf.return_value = ""
|
||||
parsed_config = parser.merge_user_and_local_config()
|
||||
parsed_config = parser.parse()
|
||||
|
||||
assert parsed_config["ignore"] == ["E123", "W234", "E111"]
|
||||
assert parsed_config["exclude"] == [
|
||||
|
|
@ -243,13 +178,11 @@ def test_parsed_hyphenated_and_underscored_names(
|
|||
parse_from_config=True,
|
||||
comma_separated_list=True,
|
||||
)
|
||||
parser = config.MergedConfigParser(optmanager, config_finder)
|
||||
parser = config.ConfigParser(optmanager, config_finder)
|
||||
|
||||
with mock.patch.object(config_finder, "local_config_files") as localcfs:
|
||||
localcfs.return_value = [config_file]
|
||||
with mock.patch.object(config_finder, "user_config_file") as usercf:
|
||||
usercf.return_value = ""
|
||||
parsed_config = parser.merge_user_and_local_config()
|
||||
parsed_config = parser.parse()
|
||||
|
||||
assert parsed_config["max_line_length"] == 110
|
||||
assert parsed_config["enable_extensions"] == ["H101", "H235"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue