Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make --ignore order consistent #1552

Merged
merged 1 commit into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/flake8/options/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ def aggregate_options(
default_values.extended_default_ignore = (
manager.extended_default_ignore.copy()
)
LOG.debug(
"Extended default ignore list: %s", list(extended_default_ignore)
)
extended_default_ignore.update(default_values.ignore)
default_values.ignore = list(extended_default_ignore)
LOG.debug("Extended default ignore list: %s", extended_default_ignore)
extended_default_ignore.extend(default_values.ignore)
default_values.ignore = extended_default_ignore
LOG.debug("Merged default ignore list: %s", default_values.ignore)

extended_default_select = manager.extended_default_select.copy()
Expand Down
9 changes: 4 additions & 5 deletions src/flake8/options/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from typing import Mapping
from typing import Optional
from typing import Sequence
from typing import Set
from typing import Tuple
from typing import Type
from typing import Union
Expand Down Expand Up @@ -353,8 +352,8 @@ def __init__(

self.config_options_dict: Dict[str, Option] = {}
self.options: List[Option] = []
self.extended_default_ignore: Set[str] = set()
self.extended_default_select: Set[str] = set()
self.extended_default_ignore: List[str] = []
self.extended_default_select: List[str] = []

self._current_group: Optional[argparse._ArgumentGroup] = None

Expand Down Expand Up @@ -415,7 +414,7 @@ def extend_default_ignore(self, error_codes: Sequence[str]) -> None:
extend the default ignore list.
"""
LOG.debug("Extending default ignore list with %r", error_codes)
self.extended_default_ignore.update(error_codes)
self.extended_default_ignore.extend(error_codes)

def extend_default_select(self, error_codes: Sequence[str]) -> None:
"""Extend the default select list with the error codes provided.
Expand All @@ -425,7 +424,7 @@ def extend_default_select(self, error_codes: Sequence[str]) -> None:
to extend the default select list.
"""
LOG.debug("Extending default select list with %r", error_codes)
self.extended_default_select.update(error_codes)
self.extended_default_select.extend(error_codes)

def parse_args(
self,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_local_plugin_can_add_option(local_config):

args = aggregator.aggregate_options(option_manager, cfg, cfg_dir, argv)

assert args.extended_default_select == {"XE", "F", "E", "W", "C90"}
assert args.extended_default_select == ["XE", "C90", "F", "E", "W"]
assert args.anopt == "foo"


Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_option_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ def test_parse_args_normalize_paths(optmanager):

def test_extend_default_ignore(optmanager):
"""Verify that we update the extended default ignore list."""
assert optmanager.extended_default_ignore == set()
assert optmanager.extended_default_ignore == []

optmanager.extend_default_ignore(["T100", "T101", "T102"])
assert optmanager.extended_default_ignore == {"T100", "T101", "T102"}
assert optmanager.extended_default_ignore == ["T100", "T101", "T102"]


def test_optparse_normalize_callback_option_legacy(optmanager):
Expand Down