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

Use dense formatting for requirement version specifiers in diagnostics #2601

Merged
merged 2 commits into from
Mar 22, 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
4 changes: 2 additions & 2 deletions crates/pep508-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl Display for Requirement {
VersionOrUrl::VersionSpecifier(version_specifier) => {
let version_specifier: Vec<String> =
version_specifier.iter().map(ToString::to_string).collect();
write!(f, " {}", version_specifier.join(", "))?;
write!(f, "{}", version_specifier.join(","))?;
}
VersionOrUrl::Url(url) => {
// We add the space for markers later if necessary
Expand Down Expand Up @@ -1627,7 +1627,7 @@ mod tests {

#[test]
fn basic_examples() {
let input = r"requests[security,tests] >=2.8.1, ==2.8.* ; python_version < '2.7'";
let input = r"requests[security,tests]>=2.8.1,==2.8.* ; python_version < '2.7'";
let requests = Requirement::from_str(input).unwrap();
assert_eq!(input, requests.to_string());
let expected = Requirement {
Expand Down
12 changes: 6 additions & 6 deletions crates/uv/tests/pip_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn check_incompatible_packages() -> Result<()> {
Installed 1 package in [TIME]
- idna==3.4
+ idna==2.4
warning: The package `requests` requires `idna <4, >=2.5`, but `2.4` is installed.
warning: The package `requests` requires `idna<4,>=2.5`, but `2.4` is installed.
"###
);

Expand All @@ -148,7 +148,7 @@ fn check_incompatible_packages() -> Result<()> {
----- stderr -----
Checked 5 packages in [TIME]
Found 1 incompatibility
The package `requests` requires `idna <4, >=2.5`, but `2.4` is installed.
The package `requests` requires `idna<4,>=2.5`, but `2.4` is installed.
"###
);

Expand Down Expand Up @@ -206,8 +206,8 @@ fn check_multiple_incompatible_packages() -> Result<()> {
+ idna==2.4
- urllib3==2.1.0
+ urllib3==1.20
warning: The package `requests` requires `idna <4, >=2.5`, but `2.4` is installed.
warning: The package `requests` requires `urllib3 <3, >=1.21.1`, but `1.20` is installed.
warning: The package `requests` requires `idna<4,>=2.5`, but `2.4` is installed.
warning: The package `requests` requires `urllib3<3,>=1.21.1`, but `1.20` is installed.
Copy link
Member

Choose a reason for hiding this comment

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

I find this one hard to read, should split name and specifier?

Copy link
Member Author

@zanieb zanieb Mar 22, 2024

Choose a reason for hiding this comment

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

The reason we don't tend to split the name and specifier is that we don't use ` so it's less ambiguous as a single statement. I'm thinking we should probably remove the "`" here for consistency with our other messaging, but it's not really a priority. I just want us to have a consistent presentation.

Another option is we use colors to separate the specifier from the name i.e. bold names.

Copy link
Member

Choose a reason for hiding this comment

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

i'd love using color for this, though still a space after the name for CI reports probably

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll look into that

"###
);

Expand All @@ -219,8 +219,8 @@ fn check_multiple_incompatible_packages() -> Result<()> {
----- stderr -----
Checked 5 packages in [TIME]
Found 2 incompatibilities
The package `requests` requires `idna <4, >=2.5`, but `2.4` is installed.
The package `requests` requires `urllib3 <3, >=1.21.1`, but `1.20` is installed.
The package `requests` requires `idna<4,>=2.5`, but `2.4` is installed.
The package `requests` requires `urllib3<3,>=1.21.1`, but `1.20` is installed.
"###
);

Expand Down
4 changes: 2 additions & 2 deletions crates/uv/tests/pip_freeze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ fn freeze_url() -> Result<()> {
iniconfig @ https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl

----- stderr -----
warning: The package `anyio` requires `idna >=2.8`, but it's not installed.
warning: The package `anyio` requires `sniffio >=1.1`, but it's not installed.
warning: The package `anyio` requires `idna>=2.8`, but it's not installed.
warning: The package `anyio` requires `sniffio>=1.1`, but it's not installed.
"###
);

Expand Down
12 changes: 6 additions & 6 deletions crates/uv/tests/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ fn allow_incompatibilities() -> Result<()> {
Installed 1 package in [TIME]
- jinja2==3.1.2
+ jinja2==2.11.3
warning: The package `flask` requires `jinja2 >=3.1.2`, but `2.11.3` is installed.
warning: The package `flask` requires `jinja2>=3.1.2`, but `2.11.3` is installed.
"###
);

Expand Down Expand Up @@ -1375,11 +1375,11 @@ fn no_deps() {
Downloaded 1 package in [TIME]
Installed 1 package in [TIME]
+ flask==3.0.0
warning: The package `flask` requires `werkzeug >=3.0.0`, but it's not installed.
warning: The package `flask` requires `jinja2 >=3.1.2`, but it's not installed.
warning: The package `flask` requires `itsdangerous >=2.1.2`, but it's not installed.
warning: The package `flask` requires `click >=8.1.3`, but it's not installed.
warning: The package `flask` requires `blinker >=1.6.2`, but it's not installed.
warning: The package `flask` requires `werkzeug>=3.0.0`, but it's not installed.
warning: The package `flask` requires `jinja2>=3.1.2`, but it's not installed.
warning: The package `flask` requires `itsdangerous>=2.1.2`, but it's not installed.
warning: The package `flask` requires `click>=8.1.3`, but it's not installed.
warning: The package `flask` requires `blinker>=1.6.2`, but it's not installed.
"###
);

Expand Down
20 changes: 10 additions & 10 deletions crates/uv/tests/pip_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2351,11 +2351,11 @@ fn sync_editable_and_registry() -> Result<()> {
Downloaded 1 package in [TIME]
Installed 1 package in [TIME]
+ black==24.1.0
warning: The package `black` requires `click >=8.0.0`, but it's not installed.
warning: The package `black` requires `mypy-extensions >=0.4.3`, but it's not installed.
warning: The package `black` requires `packaging >=22.0`, but it's not installed.
warning: The package `black` requires `pathspec >=0.9.0`, but it's not installed.
warning: The package `black` requires `platformdirs >=2`, but it's not installed.
warning: The package `black` requires `click>=8.0.0`, but it's not installed.
warning: The package `black` requires `mypy-extensions>=0.4.3`, but it's not installed.
warning: The package `black` requires `packaging>=22.0`, but it's not installed.
warning: The package `black` requires `pathspec>=0.9.0`, but it's not installed.
warning: The package `black` requires `platformdirs>=2`, but it's not installed.
"###
);

Expand Down Expand Up @@ -2455,11 +2455,11 @@ fn sync_editable_and_registry() -> Result<()> {
Installed 1 package in [TIME]
- black==0.1.0 (from file://[WORKSPACE_DIR]/scripts/editable-installs/black_editable)
+ black==23.10.0
warning: The package `black` requires `click >=8.0.0`, but it's not installed.
warning: The package `black` requires `mypy-extensions >=0.4.3`, but it's not installed.
warning: The package `black` requires `packaging >=22.0`, but it's not installed.
warning: The package `black` requires `pathspec >=0.9.0`, but it's not installed.
warning: The package `black` requires `platformdirs >=2`, but it's not installed.
warning: The package `black` requires `click>=8.0.0`, but it's not installed.
warning: The package `black` requires `mypy-extensions>=0.4.3`, but it's not installed.
warning: The package `black` requires `packaging>=22.0`, but it's not installed.
warning: The package `black` requires `pathspec>=0.9.0`, but it's not installed.
warning: The package `black` requires `platformdirs>=2`, but it's not installed.
"###
);

Expand Down
Loading