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 merging of command line options with configuration #2616

Merged
merged 1 commit into from
Oct 25, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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