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

Deprecate pip-compile --resolver=legacy #1724

Merged
merged 6 commits into from
Nov 13, 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
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ This section lists ``pip-tools`` features that are currently deprecated.
default. Use ``--no-allow-unsafe`` to keep the old behavior. It is
recommended to pass the ``--allow-unsafe`` now to adapt to the upcoming
change.
- Legacy resolver is deprecated and will be removed in future versions.
Use ``--resolver=backtracking`` instead.

A Note on Resolvers
===================
Expand Down
7 changes: 7 additions & 0 deletions piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,13 @@ def cli(
if isinstance(output_file, LazyFile): # pragma: no cover
ctx.call_on_close(safecall(output_file.close_intelligently))

if resolver_name == "legacy":
log.warning(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using Deprecation warnings from warning module? Somehow I find it better.

Copy link
Member Author

@atugushev atugushev Nov 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.python.org/3/library/exceptions.html#DeprecationWarning

DeprecationWarning
Base class for warnings about deprecated features when those warnings are intended for other Python developers.

DeprecaetionWarning is intended for developers, but pip-tools prints warning for end users. Also, it is "Ignored by the default warning filters", so it should be FutureWarning or something else.

Pure subjectivity image

vs

image

Personally, I prefer the latter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I don't mind using the warning module if you feel that's better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I +1 because it was only an observation. I am ok with both approaches. The real benefit of warnings is that they are very easy to silence from outside the application.

"WARNING: using legacy resolver is deprecated and will be removed in "
"future versions. The default resolver will be change to 'backtracking' "
"in 7.0.0 version. Specify --resolver=backtracking to silence this warning."
)

###
# Setup
###
Expand Down
14 changes: 14 additions & 0 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2546,3 +2546,17 @@ def test_failure_of_legacy_resolver_prompts_for_backtracking(
assert out.exit_code == 0, out
else: # pragma: no cover
raise AssertionError("unreachable")


def test_print_deprecation_warning_if_using_legacy_resolver(runner, current_resolver):
with open("requirements.in", "w"):
pass

out = runner.invoke(cli)
assert out.exit_code == 0, out

expected_warning = "WARNING: using legacy resolver is deprecated"
if current_resolver == "legacy":
assert expected_warning in out.stderr
else:
assert expected_warning not in out.stderr