Skip to content

Conversation

@EliteTK
Copy link
Contributor

@EliteTK EliteTK commented Dec 10, 2025

Summary

This partially addresses #17076 by adding value_hint to various arguments.

For cases where an option takes a path to either specifically a file or a directory directory, ValueHint::FilePath and ValueHint::DirPath are used respectively to try to limit the amount of noise presented by completions in shells which support it.

For cases where a URL (and only a URL, not a path) can be supplied, ValueHint::Url is used.

For cases where a python interpreter is to be specified, ValueHint::CommandName is used which will tab complete from $PATH by default, but will fall back to completing executable filenames if you start typing a path.

Finally, for the many cases where there is no built in completion which would make sense, and where default completion of a path would make no sense (e.g. a package name, or version specifier, or date) ValueHint::Other is used to explicitly disable completion.

Test Plan

Manually tested a bunch of these. These could be automated in the sense that we could snapshot the completion from zsh but I've not thought about how that could be done yet.

@EliteTK EliteTK temporarily deployed to uv-test-registries December 10, 2025 23:15 — with GitHub Actions Inactive
@konstin konstin added the enhancement New feature or improvement to existing functionality label Dec 11, 2025
@EliteTK EliteTK requested a review from konstin December 15, 2025 15:00
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.

Not deep into how shell completions work, but the code looks good.

@EliteTK EliteTK requested a review from zanieb December 15, 2025 15:31
help_heading = "Python options",
value_parser = parse_maybe_string
value_parser = parse_maybe_string,
value_hint = ValueHint::CommandName,
Copy link
Member

Choose a reason for hiding this comment

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

I think --python <version> is the most common use-case here, not passing an executable name.

Copy link
Contributor Author

@EliteTK EliteTK Dec 15, 2025

Choose a reason for hiding this comment

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

The thought process here was that if someone wants to type a version they can still do so, and we have no particular way to complete them, but if they did want to specify a python executable instead, they would have an easier time due to completions being restricted to valid executables.

The default here is to do "_default" completion on zsh, which will complete files and things like that. So CommandName actually restricts this to fewer things.

The only alternative I can think of is to make this ValueHint::Other but this would prevent zsh from ever letting you complete paths to programs or programs in your path.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should probably use Other. I don't want to encourage people to use Python executables from their PATH here, I think that's rarely a desirable pattern and can be confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough, will change these.

/// in a separate, ephemeral environment. These dependencies are allowed to conflict with those
/// specified by the project.
#[arg(long)]
#[arg(long, value_hint = ValueHint::Other)]
Copy link
Member

Choose a reason for hiding this comment

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

Editables are local directories

Copy link
Contributor Author

@EliteTK EliteTK Dec 15, 2025

Choose a reason for hiding this comment

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

I can't remember why I chose ValueHint::Other here ... I think I went into looking what an editable was and found that it could be a directory or some weird syntax. But that doesn't really justify not letting you complete directories.

Will fix.

The primary use for the python interpreter option is to specify a
version, so default completing executables may be confusing. Until we
have a more sophisticated completion here, it's appropriate to just
disable completions.
@EliteTK EliteTK temporarily deployed to uv-test-registries December 15, 2025 17:45 — with GitHub Actions Inactive
@EliteTK EliteTK requested a review from zanieb December 15, 2025 17:50
@EliteTK EliteTK merged commit 94c97b6 into main Dec 15, 2025
101 of 102 checks passed
@EliteTK EliteTK deleted the tk/completion-improvements branch December 15, 2025 18:29
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Dec 18, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.9.17` -> `0.9.18` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.9.18`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0918)

[Compare Source](astral-sh/uv@0.9.17...0.9.18)

Released on 2025-12-16.

##### Enhancements

- Add value hints to command line arguments to improve shell completion accuracy ([#&#8203;17080](astral-sh/uv#17080))
- Improve error handling in `uv publish` ([#&#8203;17096](astral-sh/uv#17096))
- Improve rendering of multiline error messages ([#&#8203;17132](astral-sh/uv#17132))
- Support redirects in `uv publish` ([#&#8203;17130](astral-sh/uv#17130))
- Include Docker images with the alpine version, e.g., `python3.x-alpine3.23` ([#&#8203;17100](astral-sh/uv#17100))

##### Configuration

- Accept `--torch-backend` in `[tool.uv]` ([#&#8203;17116](astral-sh/uv#17116))

##### Performance

- Speed up `uv cache size` ([#&#8203;17015](astral-sh/uv#17015))
- Initialize S3 signer once ([#&#8203;17092](astral-sh/uv#17092))

##### Bug fixes

- Avoid panics due to reads on failed requests ([#&#8203;17098](astral-sh/uv#17098))
- Enforce latest-version in `@latest` requests ([#&#8203;17114](astral-sh/uv#17114))
- Explicitly set `EntryType` for file entries in tar ([#&#8203;17043](astral-sh/uv#17043))
- Ignore `pyproject.toml` index username in lockfile comparison ([#&#8203;16995](astral-sh/uv#16995))
- Relax error when using `uv add` with `UV_GIT_LFS` set ([#&#8203;17127](astral-sh/uv#17127))
- Support file locks on ExFAT on macOS ([#&#8203;17115](astral-sh/uv#17115))
- Change schema for `exclude-newer` into optional string ([#&#8203;17121](astral-sh/uv#17121))

##### Documentation

- Drop arm musl caveat from Docker documentation ([#&#8203;17111](astral-sh/uv#17111))
- Fix version reference in resolver example ([#&#8203;17085](astral-sh/uv#17085))
- Better documentation for `exclude-newer*` ([#&#8203;17079](astral-sh/uv#17079))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi41Ny4xIiwidXBkYXRlZEluVmVyIjoiNDIuNTcuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants