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

Add --no-strip-extras and warn about strip extras by default #1954

Merged
merged 6 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,12 @@ This section lists `pip-tools` features that are currently deprecated.
- In the next major release, the `--allow-unsafe` behavior will be enabled by
default (https://github.com/jazzband/pip-tools/issues/989).
Use `--no-allow-unsafe` to keep the old behavior. It is recommended
to pass the `--allow-unsafe` now to adapt to the upcoming change.
to pass `--allow-unsafe` now to adapt to the upcoming change.
- The legacy resolver is deprecated and will be removed in future versions.
The new default is `--resolver=backtracking`.
- In the next major release, the `--strip-extras` behavior will be enabled by
default (https://github.com/jazzband/pip-tools/issues/1613).
Use `--no-strip-extras` to keep the old behavior.

### A Note on Resolvers

Expand Down
15 changes: 12 additions & 3 deletions piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ def _determine_linesep(
),
)
@click.option(
"--strip-extras",
"--strip-extras/--no-strip-extras",
is_flag=True,
default=False,
default=None,
help="Assure output file is constraints compatible, avoiding use of extras.",
)
@click.option(
Expand Down Expand Up @@ -365,7 +365,7 @@ def cli(
output_file: LazyFile | IO[Any] | None,
newline: str,
allow_unsafe: bool,
strip_extras: bool,
strip_extras: bool | None,
generate_hashes: bool,
reuse_hashes: bool,
src_files: tuple[str, ...],
Expand Down Expand Up @@ -676,6 +676,15 @@ def cli(
strategy=newline, filenames=(output_file.name, *src_files)
)

if strip_extras is None:
strip_extras = False
log.warning(
"WARNING: --strip-extras is becoming the default. "
ryanhiebert marked this conversation as resolved.
Show resolved Hide resolved
"To silence this warning, "
"either use --strip-extras to opt into the new default "
"or use --no-strip-extras to retain the existing behavior."
)

##
# Output
##
Expand Down
6 changes: 4 additions & 2 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2947,20 +2947,22 @@ def test_compile_recursive_extras(runner, tmp_path, current_resolver):
[
"--no-header",
"--no-annotate",
"--no-emit-find-links",
"--no-emit-options",
"--extra",
"dev",
"--find-links",
os.fspath(MINIMAL_WHEELS_PATH),
os.fspath(tmp_path / "pyproject.toml"),
"--output-file",
"-",
],
)
expected = rf"""foo @ {tmp_path.as_uri()}
small-fake-a==0.2
small-fake-b==0.3
"""
assert out.exit_code == 0
assert expected == out.stderr
assert expected == out.stdout


def test_config_option(pip_conf, runner, tmp_path, make_config_file):
Expand Down