Skip to content

Add an experimental uv format command#15017

Merged
zanieb merged 20 commits intomainfrom
zb/format-ruff
Aug 21, 2025
Merged

Add an experimental uv format command#15017
zanieb merged 20 commits intomainfrom
zb/format-ruff

Conversation

@zanieb
Copy link
Member

@zanieb zanieb commented Aug 1, 2025

As a frontend to Ruff's formatter.

There are some interesting choices here, some of which may just be temporary:

  1. We pin a default version of Ruff, so uv format is stable for a given uv version
  2. We install Ruff from GitHub instead of PyPI, which means we don't need a Python interpreter or environment
  3. We do not read the Ruff version from the dependency tree

See astral-sh/ruff#19665 for a prototype of the LSP integration.

@zanieb zanieb temporarily deployed to uv-test-registries August 1, 2025 19:07 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries August 1, 2025 19:21 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries August 1, 2025 19:43 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries August 2, 2025 12:23 — with GitHub Actions Inactive
@zanieb zanieb marked this pull request as ready for review August 7, 2025 20:53
@zanieb zanieb requested a review from konstin August 18, 2025 21:47
@zanieb
Copy link
Member Author

zanieb commented Aug 18, 2025

@konstin can you review please? I want to build on the abstractions added here.

konstin added a commit that referenced this pull request Aug 19, 2025
Inspired by #15017, mirror the blocking of `std::fs` symbols in favor of `fs_err` and block `tokio::fs` symbols in favor of `fs_err::tokio`.
konstin added a commit that referenced this pull request Aug 19, 2025
Inspired by #15017, mirror the blocking of `std::fs` symbols in favor of `fs_err` and block `tokio::fs` symbols in favor of `fs_err::tokio`.
konstin added a commit that referenced this pull request Aug 19, 2025
Inspired by #15017, mirror the blocking of `std::fs` symbols in favor of `fs_err` and block `tokio::fs` symbols in favor of `fs_err::tokio`.
/// Initialize a [`BinaryDownloadReporter`] for a single binary download.
pub(crate) fn single(printer: Printer) -> Self {
let multi_progress = MultiProgress::with_draw_target(printer.target());
let root = multi_progress.add(ProgressBar::with_draw_target(Some(1), printer.target()));
Copy link
Member

Choose a reason for hiding this comment

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

What does the Some(1) here do?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just a copy of

/// Initialize a [`PythonDownloadReporter`] for a single Python download.
pub(crate) fn single(printer: Printer) -> Self {
Self::new(printer, 1)
}
/// Initialize a [`PythonDownloadReporter`] for multiple Python downloads.
pub(crate) fn new(printer: Printer, length: u64) -> Self {
let multi_progress = MultiProgress::with_draw_target(printer.target());
let root = multi_progress.add(ProgressBar::with_draw_target(
Some(length),
printer.target(),
));
let reporter = ProgressReporter::new(root, multi_progress, printer);
Self { reporter }
}
without support for multiple items yet.

I guess we shouldn't use a MultiProgress? I don't really mind using it for consistency though.

Copy link
Member

Choose a reason for hiding this comment

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

Non-blocker here (an aesthetic problem if it shows up all, pre-existing code), but setting the length to 1 instead of None seems off, shouldn't we either set a real value or nothing?

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 I.. don't really know much about what's going on here. We can open an issue to dig into it.

konstin added a commit that referenced this pull request Aug 19, 2025
Inspired by #15017, mirror the blocking of `std::fs` symbols in favor of
`fs_err` and block `tokio::fs` symbols in favor of `fs_err::tokio`.
@zanieb zanieb temporarily deployed to uv-test-registries August 19, 2025 22:26 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries August 19, 2025 22:46 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries August 20, 2025 14:40 — with GitHub Actions Inactive
@zanieb zanieb added the preview Experimental behavior label Aug 20, 2025
@zanieb
Copy link
Member Author

zanieb commented Aug 20, 2025

I believe I've addressed all the feedback.

@zanieb zanieb temporarily deployed to uv-test-registries August 20, 2025 14:49 — with GitHub Actions Inactive
@zanieb zanieb requested a review from konstin August 20, 2025 16:02
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.

We need to fix the retries thing, everything else looks good

@zanieb zanieb temporarily deployed to uv-test-registries August 20, 2025 20:49 — with GitHub Actions Inactive
@zanieb zanieb merged commit e31f000 into main Aug 21, 2025
241 of 242 checks passed
@zanieb zanieb deleted the zb/format-ruff branch August 21, 2025 11:33
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Aug 22, 2025
This MR contains the following updates:

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

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.8.13`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0813)

[Compare Source](astral-sh/uv@0.8.12...0.8.13)

##### Enhancements

- Add `--no-install-*` arguments to `uv add` ([#&#8203;15375](astral-sh/uv#15375))
- Initialize Git prior to reading author in `uv init` ([#&#8203;15377](astral-sh/uv#15377))
- Add CUDA 129 to available torch backends ([#&#8203;15416](astral-sh/uv#15416))
- Update Pyodide to 0.28.2 ([#&#8203;15385](astral-sh/uv#15385))

##### Preview features

- Add an experimental `uv format` command ([#&#8203;15017](astral-sh/uv#15017))
- Allow version specifiers in `extra-build-dependencies` if match-runtime is explicitly `false` ([#&#8203;15420](astral-sh/uv#15420))

##### Bug fixes

- Add `triton` to `torch-backend` manifest ([#&#8203;15405](astral-sh/uv#15405))
- Avoid panicking when resolver returns stale distributions ([#&#8203;15389](astral-sh/uv#15389))
- Fix `uv_build` wheel hashes ([#&#8203;15400](astral-sh/uv#15400))
- Treat `--upgrade-package` on the command-line as overriding `upgrade = false` in configuration ([#&#8203;15395](astral-sh/uv#15395))
- Restore DockerHub publishing ([#&#8203;15381](astral-sh/uv#15381))

</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:eyJjcmVhdGVkSW5WZXIiOiI0MS44Mi4xIiwidXBkYXRlZEluVmVyIjoiNDEuODIuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
@mgaitan
Copy link

mgaitan commented Aug 22, 2025

how is it different to uvx ruff format ? seems a bit weird to be honest.

@shawnoster
Copy link

I know this is merged but not a huge fan of this. Is the uv roadmap for it to become yet another bloated tool. Calling two tools is not difficult and adheres to the the Unix tradition of a tool doing one thing and one thing well. Just one more thing to maintain in a place that doesn't need it.

Do as you do but architecturally this is a bad choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Experimental behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments