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

--fix will now default to all #3777

Merged
merged 2 commits into from
Sep 28, 2023
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
5 changes: 4 additions & 1 deletion src/ansiblelint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ def merge_fix_list_config(

When from_cli is not an empty list, we ignore the from_file value.
"""
arguments = from_file if from_cli == [cls._default] else from_cli
if not from_file:
arguments = ["all"] if from_cli == [cls._default] else from_cli
else:
arguments = from_file
for magic_value in ("none", "all"):
if magic_value in arguments and len(arguments) > 1:
msg = f"When passing '{magic_value}' to '--fix', you cannot pass other values."
Expand Down
6 changes: 3 additions & 3 deletions test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_ensure_config_are_equal(
True,
["--fix"],
"test/fixtures/config-with-write-all.yml",
[],
["all"],
id="1",
),
pytest.param(
Expand Down Expand Up @@ -128,14 +128,14 @@ def test_ensure_config_are_equal(
False,
["--fix", "examples/playbooks/example.yml"],
"test/fixtures/config-with-write-all.yml",
[],
["all"],
id="9",
),
pytest.param(
False,
["--fix", "examples/playbooks/example.yml", "non-existent.yml"],
"test/fixtures/config-with-write-all.yml",
[],
["all"],
id="10",
),
),
Expand Down
Loading