Readit News logoReadit News
thanhhaimai · 2 days ago
I'd rather `ruff` being merged with `ty` instead. `uv` for me is about package / project manager. It's not about code style. The only time `uv` should edit a code file is to update its dependencies (PEP 723).

On the other hand, both `ruff` and `ty` are about code style. They both edit the code, either to format or fix typing / lint issues. They are good candidates to be merged.

charliermarsh · 2 days ago
To clarify, `ruff` and `uv` aren't being merged. They remain separate tools. This is more about providing a simpler experience for users that don't want to think about their formatter as a separate tool.

The analogy would be to Cargo: `cargo fmt` just runs `rustfmt`, but you can also run `rustfmt` separately if you want.

WD-42 · 2 days ago
Thank you for writing software for all of us Python day-jobbers who wish we were writing Rust instead.
drdaeman · 2 days ago
Isn’t there `uv tool run ruff` already for this? Or `uv run ruff` if it’s a proper dependency? I’m not sure what’s the point of a special shortcut command, unless there are plans to make it flexible so it’ll be an abstraction over formatters (unifying ruff, black, etc).
godelski · 2 days ago
Is `uv format` supposed to be an alias for `ruff check`?

Stupidly I ran `uv format` without `--check` (no harm done and I can `git diff` it) so I didn't see the changes it made but `ruff check` does still show things that can be fixed with `ruff check --fix`. If I'm guessing correctly the difference is coming down to the fact that I have (in my submodule where all changes were made) a pyproject.toml file with ruff rules (there's also a .flake8 file. Repo is being converted). Either way, I find this a bit confusing userside. Not sure what to expect.

I think one thing I would like is that by default `uv format` spits out what files were changed like `uv format --check` does (s/Would reformat/Reformatted/g). Fine for the actual changes not to be displayed but I think this could help with error reduction. Running it again I can see it knows 68 files were changed. Where is that information being stored? It's pretty hard to grep out a number like that (`grep -R \<68\>`) and there's a lot of candidates (honestly there's nothing that looks like a good candidate).

Also, there's a `--quiet` flag, but the output is already pretty quiet. As far as I can tell the only difference is that quiet suppresses the warning (does `--quiet` also suppress errors?)

  uv format
  warning: `uv format` is experimental and may change without warning. Pass `--preview-features format` to disable this warning.
  36 files reformatted, 31 files left unchanged

  uv format --quiet
  36 files reformatted, 31 files left unchanged
I like the result for `--quiet` but I have a strong preference that `uv format` match the verbosity of `uv format --check`. I can always throw information away but not recover. I have a strong bias that it is better to fail by displaying too much information than fail by displaying too little. The latter failure mode is more harmful as the former is much more easily addressed by existing tools. If you're taking votes, that's mine.

Anyways, looking forward to seeing how this matures. Loved everything so far!

slightwinder · a day ago
> To clarify, `ruff` and `uv` aren't being merged.

ruff at least seems to be compiled into uv, as the format worked here without a local ruff. This is significant more than just an interface. Whether they are managed and developed as separate tools doesn't matter.

> This is more about providing a simpler experience for users that don't want to think about their formatter as a separate tool.

Then build a separate interface, some script/binary acting as a unified interface, maybe with its separate distribution of all tools. Pushing it into uv is just adding a burden to those who don't want this.

uv and ruff are poor names anyway, this could be used to at least introduce a good name for this everything-python-tool they seem to aim for.

rbits · 2 days ago
Does it have the capability to use a different formatter than ruff?
jgauth · 2 days ago
This is cool. Is there a way to call ruff’s linter? Like `uv lint`, which would call `ruff check`.

To your analogy, it’d be like `cargo clippy`

Deleted Comment

WD-42 · 2 days ago
They are mimicking Rust's cargo, which has `cargo fmt`
Biganon · 2 days ago
> They are mimicking Rust's cargo

Cargo cargo cult?

munificent · 2 days ago
Also `go fmt` and `dart format`.
petcat · a day ago
Doesn't cargo just have a subcommand plugin system? Or is fmt actually hard-coded into the cargo code?

I prefer the plugin system. I don't like god programs like what the npm monstrosity became.

impulser_ · 2 days ago
I think the goal is to make uv a complete package manager for Python while still giving you the option to use the parts separately.

uv is like cargo for python.

If you only need a fast type checker you can just use ty, if you just need a fast formatter and linter you can just use ruff.

Combining ruff and ty doesn't make sense if you think about like this.

RossBencina · 2 days ago
Including a formatter in a package manager doesn't make sense to me. Seems like obvious feature creep.

My understanding was that uv is for installing dependencies (e.g. like pip) with the added benefit of also installing/managing python interpreters (which can be reasonably thought of as a dependency). This makes sense. Adding more stuff doesn't make sense.

baggiponte · a day ago
i think it's good to let them experiment! cargo (and go?) offers this already, so why not.
munro · 2 days ago
But what if `ty` was also eventually merged into `uv` as well? 8-)

That's probably the vision, given all from astral.sh, but `ty` isn't ready yet.

alfalfasprout · 2 days ago
Oh please no...

The reality is, ecosystems evolve. First, we had mypy. Then more type checkers came out: pyre, pyright, etc. Then basedpyright. The era of rust arrived and now we have `ty` and `pyrefly` being worked on heavily.

On the linter side we saw flake8, black, and then ruff.

Decoupling makes adapting to evolution much easier. As long as both continue to offer LSP integrations it allows engineers to pick and chose what's best.

d0mine · 2 days ago
The whole premise of uv that you don't need to know that you can install specific python version using eg pyenv (`uv python install` or `uv run` may do it implicitly), you don't need to know about `python -m venv`/virtualenv (`uv venv`), or how to create lock files pip-tools / pipenv / poetry / etc(`uv lock`), or pipx (`uv tool install`) or `pip install`/ `pipenv install`/`poetry add` / many others (`uv add`), or how to build artifacts setuptools / hatchling / poetry way / etc (`uv build`). Other commands such as `uv sync` didn't break new ground too.

`uv format` is similar (you don't need to know about `ruff format` / black / yapf ).

darkamaul · 2 days ago
And I would think the next logical step here is to have a `uv lint` option here that runs ˋty` under the hood ?

I would love to see a world where there is a single or a set of standard commands that would prepare your python project (format, lint, test, publish). Maybe that’s the vision here?

zahlman · 2 days ago
This is the direction I expected things to go, and not something I'm especially fond of. I'll stick with UNIX-philosophy tools, thanks.
zem · 2 days ago
this is very much in line with the unix philosophy - it delegates formatting to ruff and simply provides a unified front end that calls out to the right specialized tool. think of it as a makefile.
gchamonlive · 2 days ago
There is wisdom in knowing when -- and how -- to break standards. Don't know if this is the case, but I think it is. If introducing fmt powers to UV meant it had to consider tradeoffs elsewhere where it might hurt its quality somehow then maybe, but in this case UV is more like an umbrella, unifying the interface for pip, venv, builds... And now fmt. All keeping each separate domain isolated without details leaking to one another.
Kinrany · 2 days ago
The spirit of the unix philosophy is not implementing MxN use cases separately. Running the same program as a separate binary or as a subcommand has nothing to do with it
cedws · 2 days ago
I mean, Go was designed by one of the authors of UNIX, and that has very much batteries-included tooling.

Dead Comment

alkh · 2 days ago
I enjoy using uv a lot but am getting afraid that it is getting bloated for no reason. For ex., the number of niche flags that a lot of subcommands support is very high + some of them seemingly achieve the same result(uv run --no-project and uv run --active). I'd rather them working on improving existing tools and documentation than adding new (redundant) functionality
benreesman · 2 days ago
It's really difficult to do Python projects in a sound, reproducible, reasonably portable way. uv sync is in general able to build you only a package set that it can promise to build again.

But it can't in general build torch-tensorrt or flash-attn because it has no way of knowing if Mercury was in retrograde when you ran pip. They are trying to thread a delicate an economically pivotal needle: the Python community prizes privatizing the profits and socializing the costs of "works on my box".

The cost of making the software deployable, secure, repeatable, reliable didn't go away! It just became someone else's problem at a later time in a different place with far fewer degrees of freedom.

Doing this in a way that satisfies serious operations people without alienating the "works on my box...sometimes" crowd is The Lord's Work.

kouteiheika · 2 days ago
> But it can't in general build torch-tensorrt or flash-attn because it has no way of knowing if Mercury was in retrograde when you ran pip.

This is a self-inflicted wound, since flash attention insist on building a native C++ extension which is completely unnecessary in this case.

What you can do is the following:

1) Compile your CUDA kernels offline. 2) Include those compiled kernels in a package you push to pypi. 3) Call into the kernels with pure Python, without going through a C++ extension.

I do this for the CUDA kernels I maintain and it works great.

Flash attention currently publishes 48 (!) different packages[1], for different combinations of pytorch and C++ ABI. With this approach it would have to only publish one, and it would work for every combination of Python and pytorch.

[1] - https://github.com/Dao-AILab/flash-attention/releases/tag/v2...

darkamaul · 2 days ago
I don’t understand why adding a subcommand to uv is being considered bloat.

uv is already a complex tool, but it has excellent documentation. Adding a straightforward, self-explanatory subcommand like this doesn’t seem out of place.

zelphirkalt · 2 days ago
Developing a good and configurable formatter is a project almost as complex as uv's main focus, managing packages. As such it will divert time and attention from its main purpose and the outcome is questionable, considering how many bad formatters are out there. For example the "opinionated" black is terrible and has no awareness of semantics.
doctorpangloss · a day ago
> I don’t understand why adding a subcommand to uv is being considered bloat.

It's simple:

- Everything I use and I see: good

- Everything I don't use and I see: bloat

- Everything I use and I don't see: good

- Everything I think I don't use and I don't see: Java

fluidcruft · a day ago
When talking about uv, this comes across similar to saying that "the 'make' command has too many targets".
treyd · 2 days ago
Are they baked into the main executable or are they separate binaries (a la apt, cargo, etc)?
charliermarsh · 2 days ago
It's a separate binary -- we install Ruff if you invoke `uv format`. So if you don't invoke `uv format`, there's no impact on the binary size, etc.
IshKebab · 2 days ago
This is obviously a great move. I don't know why so many commenters here are against making things better. "Can't you just do <this slightly worse thing> already?". Well yes. But it's slightly worse.
wasabi991011 · 2 days ago
I don't think being one word longer ("uvx ruff format" vs "uv format") counts as being is worse.

I think it is much worse to create a special case that obscures the actual formatter being run and how it is being run (is ruff now preinstalled, or is it downloaded and cached in the same way as other tools?)

wiseowise · a day ago
Let me rewrite your comment a little bit to make clearer what you’re saying.

> I don’t think additional complexity counts as being worse.

Yes, it does.

Feuilles_Mortes · 2 days ago
But you have to know about ruff. I didn't, but I did know about uv.
lugao · a day ago
Strong agree, they can even make the formatter configurable in pyproject if you want to use something else.
Spivak · 2 days ago
I think the biggest thing is that it doesn't seem to support other formatters. If my project uses black I don't get to have uv format work for me.
nmca · 2 days ago
right, but you definitely shouldn’t be using any other formatter than ruff and this helps with that
nikisweeting · 2 days ago
fwiw `ruff format` includes nearly all the black rules by default / supports a superset of black's options https://astral.sh/blog/the-ruff-formatter
nickserv · 2 days ago
Ruff pretty much follows the same rules as black, and can be made identical with some options tweaking.

So when I moved several projects from black to ruff, there were no changes made to the code.

rcarmo · 2 days ago
This feels like feature creep. I've been using uv more and more over the past year (mostly because I work with projects that use it) and although I like it and recognize the advantages, it is still not my first choice, and this kind of thing isn't going to help that...
asa400 · 2 days ago
What's wrong with this approach specifically? Go does it this way. Rust does it this way. Elixir does it this way. It reduces the toil in setting up and using projects in those ecosystems substantially. It unifies community effort behind a common set of tools and provides beginners and experts alike with a shared entrypoint to projects.
RossBencina · 2 days ago
What's wrong with the approach is that it goes against basic principles of the Python ecosystem. Python has always followed the policy of standardising mechanisms and allowing implementations to develop and peacefully coexist. The Python way fosters diversity of implementations. Note that uv itself would not be a reasonable project if not for Python's approach to diverse tooling.

You cite good examples where other languages have chosen to standardise tooling. We can discuss the pros and cons of that choice. But it is a choice, and Python already made a different choice.

fluidcruft · 2 days ago
One thing I wonder about is what happens in pyproject? Do you use tool.ruff/tool.ruff.format or tool.uv.format or what? Are people who only know "uv format" supposed to understand that part? Does ruff start honoring tool.uv.format? Which have priority over which in search. Does it behave differently when you run uv format vs ruff format? etc
actinium226 · 2 days ago
What is your first choice?
rcarmo · 2 days ago
Pip, because it introduces no third-party software. This is critical in regulated industries.

Deleted Comment

Cogito · 2 days ago
I anticipate this will make it much easier for me to get my little team of actuaries formatting their code.

The impact of uv on our onboarding and utilisation of python has already been huge, and any way I can easily improve their code hygiene is a good one. Yes, I could get them to use ruff standalone, or set up pre-commit hooks etc for them, but the simple mental model that comes from `uv <do something>` is really beneficial.

Will have a play around with this and see how it goes. Would love to be able to hook into other formatters too, but not sure if that's easy or even possible already. For example, I would love it if `uv format` also formatted our SQL/dbt models.

kstrauser · 2 days ago
At that point I think you start wanting Makefiles, or preferably IMO justfiles. Then you can run `just format` and have it format your combined Python/SQL/Bash/TypeScript project.
amanzi · 2 days ago
It wouldn't surprise me if the ruff featurset eventually gets integrated into uv and ty. The linting seems to better suited to ty which would be able to provide more intelligent linting since it understands the codebase better. And the formatting seems better suited to uv since that's all about managing your project.
IAmLiterallyAB · 2 days ago
ty is already in the same repo as ruff, so integrating seems likely
infamia · 2 days ago
Mixing a package manager, (which is needed for prod package installs) with dev-only tooling is analogous to an "attractive nuisance" (not that I'm saying anyone is a child mind). I know Go and Rust do it, but thinking from first principles, it sounds like a bad idea.
kstrauser · 2 days ago
It really does sound like a bad idea, and now that I've used cargo a lot, I want a lot more of those bad ideas in my life.

Seriously, if uv becomes to Python what cargo is to Rust, the developer experience for Python is going to be vastly better than before. I've been writing Python professionally for more than 25 years, and getting paid to work around it's crummier parts, and I'm thrilled to be able to throw away all that knowledge and just use uv.

calmbonsai · 2 days ago
I see zero need for this given that excellent time-testing code formatting tooling options are already available.

This smacks of feature-creep and I won't be incorporating it into any pipelines for the foreseeable future.

charliermarsh · 2 days ago
`uv format` is just a front-end for `ruff format`. It isn't introducing a new formatter to the ecosystem or anything like that.
nikisweeting · 2 days ago
You realize this is just a shortcut for one of those "time-tested" options, right? ruff format is already widely used.
calmbonsai · 2 days ago
But why bundle? It makes zero design sense to me.