Skip to content

Commit

Permalink
--fix will now default to all (#3777)
Browse files Browse the repository at this point in the history
  • Loading branch information
audgirka committed Sep 28, 2023
1 parent 53421b2 commit 59f4141
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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

0 comments on commit 59f4141

Please sign in to comment.