Skip to content

Commit 816ee19

Browse files
committed
Update to support click >= 8.3
The latest `click` release makes two changes which are visible in `pip-tools`, one of which is only seen in the testsuite. 1. The default for `Parameter.default` is now an internal `UNSET` sentinel. Because `UNSET` isn't in the public API, checking `Option.default` is not the right way to check if an option has no explicit default value. We could use `Option.to_info_dict()`, but we're *also* checking for a falsy value right now -- the simple fix is to check for a parsed value of `None`. 2. Changes to EOF handling in `CliRunner.isolation()` result in the stream being closed on exit. Between pallets/click#2934 and pallets/click#2940, we now get the intended behavior for `CliRunner.isolation()`, in that it outputs an EOF when the context manager exits. To solve, update a test to read stderr before exiting the context manager.
1 parent b97a0d4 commit 816ee19

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

changelog.d/2235.bugfix.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix an incompatibility with `click>=8.3` which made `pip-compile` display incorrect
2+
options in the compile command in output headers -- by :user:`sirosen`.

piptools/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def get_compile_command(click_ctx: click.Context) -> str:
399399
continue
400400

401401
# Skip options without a value
402-
if option.default is None and not value:
402+
if value is None:
403403
continue
404404

405405
# Skip options with a default value

tests/test_logging.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def test_indentation(runner):
1010
log = LogContext(indent_width=2)
1111

1212
with runner.isolation() as streams:
13-
stderr = streams[1]
1413
log.log("Test message 1")
1514
with log.indentation():
1615
log.log("Test message 2")
@@ -19,7 +18,9 @@ def test_indentation(runner):
1918
log.log("Test message 4")
2019
log.log("Test message 5")
2120

22-
assert stderr.getvalue().decode().splitlines() == [
21+
stderr_bytes = streams[1].getvalue()
22+
23+
assert stderr_bytes.decode().splitlines() == [
2324
"Test message 1",
2425
" Test message 2",
2526
" Test message 3",

0 commit comments

Comments
 (0)