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 relative paths for user display #2559

Merged
merged 2 commits into from
Mar 20, 2024
Merged

Use relative paths for user display #2559

merged 2 commits into from
Mar 20, 2024

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Mar 20, 2024

Summary

This PR changes our user-facing representation for paths to use relative paths, when the path is within the current working directory. This mirrors what we do in Ruff. (If the path is outside the current working directory, we print an absolute path.)

Before:

❯ uv venv .venv2
Using Python 3.12.2 interpreter at: /Users/crmarsh/workspace/uv/.venv/bin/python3
Creating virtualenv at: .venv2
Activate with: source .venv2/bin/activate

After:

❯ cargo run venv .venv2
    Finished dev [unoptimized + debuginfo] target(s) in 0.15s
     Running `target/debug/uv venv .venv2`
Using Python 3.12.2 interpreter at: .venv/bin/python3
Creating virtualenv at: .venv2
Activate with: source .venv2/bin/activate

Note that we still want to use the existing .simplified_display() anywhere that the path is being simplified, but still intended for machine consumption (e.g., when passing to .current_dir()).

@zanieb
Copy link
Member

zanieb commented Mar 20, 2024

+1 I prefer this strongly.

I would be careful with cases where the user provides something relative but stepping upwards like ./../../foo

@charliermarsh charliermarsh added the cli Related to the command line interface label Mar 20, 2024
@charliermarsh charliermarsh force-pushed the charlie/relativize branch 3 times, most recently from e3454e3 to 19856a4 Compare March 20, 2024 02:44
@charliermarsh charliermarsh marked this pull request as ready for review March 20, 2024 02:45
@charliermarsh charliermarsh marked this pull request as draft March 20, 2024 02:58
@charliermarsh charliermarsh force-pushed the charlie/relativize branch 5 times, most recently from 524e2fa to 1b1821c Compare March 20, 2024 03:55
@charliermarsh charliermarsh marked this pull request as ready for review March 20, 2024 04:17
@charliermarsh charliermarsh requested review from zanieb and konstin and removed request for zanieb March 20, 2024 04:17
Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

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

Much better

"Activate with: source /home/ferris/project/.venv/bin/activate",
),
(filter_prompt, "Activate with: source .venv/bin/activate"),
(&filter_venv, ".venv"),
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this filter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, for some reason on macOS these paths are sometimes prefixed with /private/

@charliermarsh charliermarsh merged commit 00fc440 into main Mar 20, 2024
31 checks passed
@charliermarsh charliermarsh deleted the charlie/relativize branch March 20, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants