Skip to content

Commit

Permalink
Merge pull request #1989 from chrysle/fix-inverted-options-ignored
Browse files Browse the repository at this point in the history
Fix ignorance of inverted CLI options in config for `pip-sync`
  • Loading branch information
webknjaz authored Nov 26, 2023
2 parents f20d6ae + 5e8fbee commit fb93ad7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions piptools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,13 @@ def _invert_negative_bool_options_in_config(
# Transform config key to its equivalent in the CLI
long_option = _convert_to_long_option(key)
new_key = cli_opts[long_option].name if long_option in cli_opts else key
negative_option_prefix = "no_"
assert new_key is not None
if (
new_key.startswith(negative_option_prefix)
and long_option not in ONLY_NEGATIVE_OPTIONS
):
new_key = new_key[len(negative_option_prefix) :]

# Invert negative boolean according to the CLI
new_value = (
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3481,7 +3481,7 @@ def test_invalid_cli_boolean_flag_config_option_captured(
out = runner.invoke(cli, [req_in.as_posix(), "--config", config_file.as_posix()])

assert out.exit_code == 2
assert "No such config key 'no_annnotate'." in out.stderr
assert "No such config key 'annnotate'." in out.stderr


strip_extras_warning = (
Expand Down

0 comments on commit fb93ad7

Please sign in to comment.