Skip to content

Commit

Permalink
Fix merging of command line options with configuration (#2616)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ssbarnea authored Oct 25, 2022
1 parent dc5e194 commit ce526bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/ansiblelint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,13 @@ def merge_config(file_config: dict[Any, Any], cli_config: Namespace) -> Namespac
return cli_config

for entry in bools:
v = getattr(cli_config, entry) or file_config.pop(entry, False)
file_value = file_config.pop(entry, False)
v = getattr(cli_config, entry) or file_value
setattr(cli_config, entry, v)

for entry, default in scalar_map.items():
v = getattr(cli_config, entry, None) or file_config.pop(entry, default)
file_value = file_config.pop(entry, default)
v = getattr(cli_config, entry, None) or file_value
setattr(cli_config, entry, v)

# if either commandline parameter or config file option is set merge
Expand Down
2 changes: 0 additions & 2 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,6 @@ def test_cli_auto_detect(capfd: CaptureFixture[str]) -> None:
assert "Identified: .github/" not in out
# assures that we can parse playbooks as playbooks
assert "Identified: test/test/always-run-success.yml" not in err
# assure that zuul_return missing module is not reported
assert "examples/playbooks/mocked_dependency.yml" not in out
assert "Executing syntax check on examples/playbooks/mocked_dependency.yml" in err


Expand Down

0 comments on commit ce526bd

Please sign in to comment.