Skip to content

Commit ce526bd

Browse files
authored
Fix merging of command line options with configuration (#2616)
Fixed bug which prevented use of command line options that were booleans or scalar when these were also defined in configuration file. The root cause was that the did not pop them from the dictionary when the command line options where present.
1 parent dc5e194 commit ce526bd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/ansiblelint/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,13 @@ def merge_config(file_config: dict[Any, Any], cli_config: Namespace) -> Namespac
474474
return cli_config
475475

476476
for entry in bools:
477-
v = getattr(cli_config, entry) or file_config.pop(entry, False)
477+
file_value = file_config.pop(entry, False)
478+
v = getattr(cli_config, entry) or file_value
478479
setattr(cli_config, entry, v)
479480

480481
for entry, default in scalar_map.items():
481-
v = getattr(cli_config, entry, None) or file_config.pop(entry, default)
482+
file_value = file_config.pop(entry, default)
483+
v = getattr(cli_config, entry, None) or file_value
482484
setattr(cli_config, entry, v)
483485

484486
# if either commandline parameter or config file option is set merge

test/test_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,6 @@ def test_cli_auto_detect(capfd: CaptureFixture[str]) -> None:
326326
assert "Identified: .github/" not in out
327327
# assures that we can parse playbooks as playbooks
328328
assert "Identified: test/test/always-run-success.yml" not in err
329-
# assure that zuul_return missing module is not reported
330-
assert "examples/playbooks/mocked_dependency.yml" not in out
331329
assert "Executing syntax check on examples/playbooks/mocked_dependency.yml" in err
332330

333331

0 commit comments

Comments
 (0)