Skip to content

Commit

Permalink
Improve formatting of package ranges in error messages (#864)
Browse files Browse the repository at this point in the history
Closes #810
Closes #812
Requires astral-sh/pubgrub#19 and
astral-sh/pubgrub#18

- Always pair package ranges with names e.g. `... of a matching a<1.0`
instead of `... of a matching <1.0`
- Split range segments onto multiple lines when not a singleton as
suggested in
[#850](#850 (comment))
- Improve formatting when ranges are split across multiple lines e.g. by
avoiding extra spaces and improving wording

Note review will require expanding the hidden files as there are
significant changes to the report formatter and snapshots.

Bear with me here as these are definitely not perfect still.

The following changes build on top of this independently for further
improvements:
- #868 
- #867 
- #866 
- #871
  • Loading branch information
zanieb authored Jan 10, 2024
1 parent 4d8bfd7 commit 93d3093
Show file tree
Hide file tree
Showing 7 changed files with 505 additions and 106 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ owo-colors = { version = "3.5.0" }
petgraph = { version = "0.6.4" }
platform-info = { version = "2.0.2" }
plist = { version = "1.6.0" }
pubgrub = { git = "https://github.com/zanieb/pubgrub", rev = "866c0f2a87fee1e8abe804d40a2ee934de0973d7" }
pubgrub = { git = "https://github.com/zanieb/pubgrub", rev = "0e02ea9fc8d021fb6a6b9e77b09ade4332068f42" }
pyo3 = { version = "0.20.2" }
pyo3-log = { version = "0.9.0"}
pyproject-toml = { version = "0.8.1" }
Expand Down
29 changes: 18 additions & 11 deletions crates/puffin-cli/tests/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,11 @@ fn compile_python_37() -> Result<()> {
----- stderr -----
× No solution found when resolving dependencies:
╰─▶ Because there are no versions of Python>=3.8 and black==23.10.1 depends
on Python>=3.8, black==23.10.1 is forbidden.
And because root depends on black==23.10.1, version solving failed.
╰─▶ Because there are no versions of Python that satisfy Python>=3.8
and black==23.10.1 depends on Python>=3.8, we can conclude that
black==23.10.1 is forbidden.
And because root depends on black==23.10.1 we can conclude that the
requirements are unsatisfiable.
"###);
});

Expand Down Expand Up @@ -1407,8 +1409,9 @@ fn conflicting_direct_url_dependency() -> Result<()> {
----- stderr -----
× No solution found when resolving dependencies:
╰─▶ Because there is no version of werkzeug==3.0.0 and root depends on
werkzeug==3.0.0, version solving failed.
╰─▶ Because there is no version of werkzeug==3.0.0 and root depends
on werkzeug==3.0.0, we can conclude that the requirements are
unsatisfiable.
"###);
});

Expand Down Expand Up @@ -1558,8 +1561,10 @@ fn conflicting_transitive_url_dependency() -> Result<()> {
----- stderr -----
× No solution found when resolving dependencies:
╰─▶ Because flask==3.0.0 depends on werkzeug>=3.0.0 and there are no
versions of werkzeug>=3.0.0, flask==3.0.0 is forbidden.
And because root depends on flask==3.0.0, version solving failed.
versions of werkzeug that satisfy werkzeug>=3.0.0, we can conclude that
flask==3.0.0 is forbidden.
And because root depends on flask==3.0.0 we can conclude that the
requirements are unsatisfiable.
"###);
});

Expand Down Expand Up @@ -1901,8 +1906,9 @@ dependencies = ["django==300.1.4"]
----- stderr -----
× No solution found when resolving dependencies:
╰─▶ Because there is no version of django==300.1.4 and my-project depends on
django==300.1.4, version solving failed.
╰─▶ Because there is no version of django==300.1.4 and my-project
depends on django==300.1.4, we can conclude that the requirements are
unsatisfiable.
"###);
});

Expand Down Expand Up @@ -2227,8 +2233,9 @@ fn compile_yanked_version_indirect() -> Result<()> {
----- stderr -----
× No solution found when resolving dependencies:
╰─▶ Because there are no versions of attrs>20.3.0, <21.2.0 and root depends
on attrs>20.3.0, <21.2.0, version solving failed.
╰─▶ Because there are no versions of attrs that satisfy attrs>20.3.0,<21.2.0
and root depends on attrs>20.3.0,<21.2.0, we can conclude that the
requirements are unsatisfiable.
"###);
});

Expand Down
7 changes: 4 additions & 3 deletions crates/puffin-cli/tests/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ fn no_solution() -> Result<()> {
----- stderr -----
× No solution found when resolving dependencies:
╰─▶ Because there are no versions of flask>3.0.0 and flask==3.0.0 depends on
werkzeug>=3.0.0, flask>=3.0.0 depends on werkzeug>=3.0.0.
╰─▶ Because there are no versions of flask that satisfy flask>3.0.0
and flask==3.0.0 depends on werkzeug>=3.0.0, we can conclude that
flask>=3.0.0 depends on werkzeug>=3.0.0.
And because root depends on flask>=3.0.0 and root depends on
werkzeug<1.0.0, version solving failed.
werkzeug<1.0.0, we can conclude that the requirements are unsatisfiable.
"###);

Ok(())
Expand Down
Loading

0 comments on commit 93d3093

Please sign in to comment.