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 pip-compile to properly exclude non-relevant options from output header #2066

Merged
merged 1 commit into from
Mar 11, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion piptools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,14 @@ def get_compile_command(click_ctx: click.Context) -> str:
# Get the latest option name (usually it'll be a long name)
option_long_name = option.opts[-1]

negative_option = None
if option.is_flag and option.secondary_opts:
# get inverse flag --no-{option_long_name}
negative_option = option.secondary_opts[-1]

# Exclude one-off options (--upgrade/--upgrade-package/--rebuild/...)
# or options that don't change compile behaviour (--verbose/--dry-run/...)
if option_long_name in COMPILE_EXCLUDE_OPTIONS:
if {option_long_name, negative_option} & COMPILE_EXCLUDE_OPTIONS:
continue

# Exclude config option if it's the default one
Expand Down
2 changes: 2 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ def test_is_url_requirement_filename(caplog, from_line, line):
(["--upgrade"], "pip-compile"),
(["-P", "django"], "pip-compile"),
(["--upgrade-package", "django"], "pip-compile"),
(["--reuse-hashes"], "pip-compile"),
(["--no-reuse-hashes"], "pip-compile"),
# Check options
(["--max-rounds", "42"], "pip-compile --max-rounds=42"),
(["--index-url", "https://foo"], "pip-compile --index-url=https://foo"),
Expand Down
Loading