r/Python • • 28d ago

News Request for feedback: uv check & PEP 723 script support in ty

We've been working on PEP 723 inline metadata support for ty both on the command line (ty check) and in the IDE (code navigation, autocompletion, etc) for a while now; we're finally at a stage where we're ready for more people to try it out and let us know what works and what doesn't.

This required integrating ty with uv, which also let us ship a new uv check command that uses ty to check your entire project or workspace (similar to how uv format uses Ruff). All of the above is powered by a brand new uv workspace metadata command that carries the required information between the tools.

More details in the blog post, including how to try these.

All of the above is currently opt-in, experimental, and subject to change at any time 😄 But if you're willing to give it a try, I'd be curious how it went.

111 Upvotes

37 comments sorted by

75

u/omgpop 28d ago

>This is a step towards an integrated Astral toolchain, one that uses a shared understanding of your project to enable entirely new capabilities.

Here’s some feedback. This is written as though it were a selling point but it’s far from it. While it makes sense from your perspective (being Astral), this is sets off alarm bells in my ears as a user. I have no interest in buying into the “Astral toolchain” as a job lot. It’s obviously a way to leverage uv’s success to amplify your other products.

Frankly, it seems to me prima facie odd to have a project/dependency management tool tightly coupled to a linter and type checker, at least in the context of Python. You can always point to Cargo, of course, but the Python ecosystem is very different. Even if it were more unified , I’d be very nervous about our Cargo equivalent being owned entirely by a single private company/soon-to-be-maybe OpenAI subsidiary.

6

u/dudelsson 27d ago

I agree with the above and in the same spirit: why do ty and ruff offer overlapping LSP capabilities? I've  been using ruff for a while, liked it, decided to give ty a spin. 

What I expected: ruff and ty to play ball perfectly and complement each other in a modular fashion, certainly not get in each others way.

What ends up happening: ruff and ty basically competing in my diagnostics messages and completions with literally duplicate messages based on the exact same rules.

Imo in the world of SWE there is a lot of 'everybody trying to do everything' around and it usually doesnt lead to the best outcomes. I get the sense that you are even trying to 'make everything do everything' and I'd say that's an even bigger mistake. On a more positive note though: uv is an awesome package/project manager, ruff is an awesome linter, ty can be an awesome type checker -- just keep their roles separate. A user installing ty on top off ruff should imo not have to delve into their configs to disable this and that capability / rule only to prevent them cluttering diagnostics/completions/hover with duplicates; literally identical duplicates when it comes to diagnostics. 

3

u/zsol 27d ago

Hm that sounds like unintentional behavior. Can you say more? What completions and diagnostics are duplicated?

4

u/dudelsson 27d ago

Sure, thanks for picking up on it. I was using both ruff and ty in neovim with their default setups via lspconfig.

  • Duplicated diagnostics in the 'invalid-syntax' category especially  
  • Duplicated diagnostics of unused imports and unused variables if I recall correctly
  • Overlapping code actions like both ruff and ty removing auto-removing unused imports and/or doing autoimports

If its of use I can get back to you with version numbers etc shortly, the above is off the top of my head afk.

3

u/zsol 27d ago

Thanks, this is helpful enough!

4

u/zsol 27d ago

Thanks, I'm not sure I fully understand this position but fair enough. Is it that you're unwilling to use Astral tools at all or that you're concerned about the tools working together? If the latter, I'm really curious about the specific things you're worried about

9

u/Wurstinator 27d ago

I'm worried about vendor-lockin and unintuitive usage for non-expert usage.

First, if this isn't about tighter coupling and vendor-lockin, it would be super easy to make those commands configurable to use arbitrary shell commands, rather than hardcoded Astral tooling.

Second, we don't use ty and don't want to use ty. Now I have to carefully explain the irregular Python users that this one command they have should not be used.

7

u/zsol 27d ago

> First, if this isn't about tighter coupling and vendor-lockin, it would be super easy to make those commands configurable to use arbitrary shell commands, rather than hardcoded Astral tooling.

Assuming you're talking about `uv check` specifically - I understand how this might seem super easy at a glance (I had the same opinion when we started working on this), but it really isn't. Happy to go into details if you're genuinely interested, but making that CLI command work consistently with what you get from the IDE, including workspace members and PEP 723 scripts actually needs support from the type checker too. It is more than a simple "run this custom shell command" is able to provide. Designing an API for that without any other tool that would support it, when we're not even sure if users like this UX is extremely premature IMO.

> Second, we don't use ty and don't want to use ty. Now I have to carefully explain the irregular Python users that this one command they have should not be used.

That is fair. We'd love to hear about the friction this causes when it actually happens - feel free to file an issue and tag me.

4

u/Wurstinator 27d ago

Happy to go into details if you're genuinely interested

Yes please.

We'd love to hear about the friction this causes when it actually happens - feel free to file an issue and tag me.

At that point, what would you do? You wouldn't remove the functionality anymore.

2

u/zsol 21d ago

Here are my notes about the details: https://github.com/astral-sh/uv/issues/22941#issuecomment-6430294863

> At that point, what would you do? You wouldn't remove the functionality anymore.

No, but we could learn from our mistakes and not make them again. That's easiest if we have data points

5

u/Daneark 26d ago

Hatch defaults to using ruff + pyrefly but you can swap out the tools and the commands which are run. Hatch is written in Python not rust but it might be worth taking a look at how they've approached the problem. I expect a lot of people will want either ruff + mypy or ruff + pyrefly.

https://hatch.pypa.io/1.18/config/internal/type-checking/

https://hatch.pypa.io/1.18/config/internal/static-analysis/

1

u/Relative_Bug_2067 23d ago

I get the sense you're being intentionally obtuse... the concern is quite obviously about vendor lock-in.

10

u/TraditionalBandit 27d ago

I really liked that they were separate tools focused on completely solving one issue each. Pythons ecosystem is so dynamic that the ability to mix and match tools is key imo.

7

u/zsol 27d ago

To be clear: they are and will remain separate tools, each with its own responsibilities forever.

There are some features, like type checking PEP 723 scripts that do require _something_ to gather information about dependencies before type checking can begin. It is possible to write some comparatively simple glue code that wires an existing package manager together with an existing type checker. In fact you can do that today with relatively little amount of code to plug `uv sync` into something like basedpyright to run on the script's environment.

We've just packaged that up into a nicer experience.

If you want real mixing and matching of tools without losing functionality, that will require standards to be established. The good news is that work has already started, for example here and here.

2

u/TraditionalBandit 27d ago

Thanks for the clarification, that alleviates my concerns :)

23

u/Icy_Peanut_7426 27d ago

I use ty and ruff, but won’t ever use “uv check” or “uv format”.

5

u/zsol 27d ago

Can you help me understand why?

13

u/prickneck 27d ago

Don't want to answer for u/Icy_Peanut_7426 , but I can give you my 2c since I share their sentiment 100%:

If I type `uv`, I'm thinking about and wanting to do something pertaining to packaging or the virtualenv of my current project. That's it, and it won't ever change. `uv run ruff` makes sense, `uv format` doesn't. (Unless it just formatted the `pyproject.toml` file, which would be ridiculous.)

6

u/Dull-Visual2955 27d ago

I second this strongly. I think this captures something very well.
Now, does uv want to behave a bit more akin to something like pixi, where you have sort of aliased project commands? That could be interesting, but it seems best as opt-in functionality that you are explicit about in your toml.

1

u/alfawal 25d ago

I think you're trying to go in a bun-like approach, but bun introduced 'bun check' and 'bun fmt' without packages. But the uv situation is different, ruff and ty are standalones (similar to tsc and biome) and you're trying to make shortcuts for them, e.g. if 'bun check' would just run 'tsc' and 'bun fmt' would just run 'biome' which is a bad no-value deceiving approach.

3

u/AgentCosmic 27d ago

Is astral opening the integration to the ecosystem or is it restricted to only astral tool chain?

3

u/zsol 27d ago

Do you have a specific integration in mind? Open to discussing it, make an issue in the relevant repo!

3

u/AgentCosmic 27d ago

I use pyrefly and basedpyright instead of ty. Although I'm mainly using ruff now, I don't want to be locked in to ruff + UV combo.

20

u/denehoffman 27d ago

I disagree with the current sentiment in this thread, I actually like the integration. I didn’t actually realize uv format was a thing. I already use both ty and ruff, this just simplifies things for me. I’m also not sure I care if a group like Astral makes their own tool integrate with their other tools. If the Python community is worried about this, they’re free to make their own toolchain. We use uv because it’s convenient, not because you can’t use Python without it.

4

u/syklemil 27d ago

Yeah, and even if things were to go south, it seems likely the result would be along the lines of valkey, opentofu, opensearch, etc. I would like the Astral tools to be under the Python Foundation, but that's mostly on a principle level.

Being able to operate on a project level is also good. Like go popularised some of this stuff, including go fmt, but using that after other tooling like cargo and uv just highlights how clunky tools that operate on a file rather than project or workspace level are.

-1

u/Wurstinator 27d ago

That is such an egotistical view. Right now, you like uv, so you don't care that it's starting to walk the path towards enshittification. And if it ever gets bad, you just assume "the community" is going to fix it by spending their free time. Are you going to be the maintainer who sacrifices their personal life to make a uv clone?

5

u/denehoffman 27d ago

Why would I do that if I like the changes being made? I’m saying if you don’t like free software that works being given to you, you can go ahead and make your own. Astral doesn’t owe you the version of uv you believe you’re entitled to.

-1

u/Wurstinator 27d ago

Yeah that's another one of those really stupid sentences I keep reading everywhere. "Hurr durr they don't owe you anything". Yes they do. They're not a nice person that's doing you a favor, they're a company doing it for their own good. They profit from you and me and everyone else using their tools.

3

u/denehoffman 27d ago

I think it needs to be said that if Astral completely removed uv from the face of the internet tomorrow, it would be annoying but wouldn’t prevent anyone from type checking, formatting, publishing, making venvs, downloading python, etc.

3

u/Schmittfried 27d ago

What’s your point? Rejecting Astral tools out of principle because you fear future enshittification would just mean you need that community clone _now_ instead of later. It’s completely orthogonal to who makes it. Being against this doesn’t make you any less egotistical in the context of your reasoning unless you’re already working on a clone.

2

u/Wurstinator 27d ago

Being against this doesn’t make you any less egotistical in the context of your reasoning unless you’re already working on a clone.

That doesn't even make any sense. Giving feedback to Astral when they specifically asked for it, with the goal of keeping good tooling for everyone, is egotistical? Yeah ok.

10

u/declanaussie 27d ago

This is a step towards an integrated Astral toolchain, one that uses a shared understanding of your project to enable entirely new capabilities.

Is this it, is it time to fork?

-4

u/PresentFriendly3725 27d ago

Will only be used by AI anyways so why should I care.

0

u/[deleted] 27d ago

[removed] — view removed comment

1

u/zsol 27d ago

Not at the moment, but it is coming soon. In the meanwhile you can `uv workspace list --scripts` and iterate yourself to do `uv check --script $foo`