Top
Best
New

Posted by brianzelip 10/14/2025

Pyrefly: Python type checker and language server in Rust(pyrefly.org)
203 points | 144 commentspage 2
rasulkireev 10/14/2025|
This looks interesting. But I decided to go with ty in my projects, for the incremental approach.
codethief 10/14/2025|
How well does ty work these days? Last time I checked it still produced a lot of false positives and false negatives. (Which was very much expected, given its alpha/WIP status.)
rasulkireev 10/14/2025||
Honestly i barely use it, just started to give it a try by adding types where it makes most sense and running with pre-commit. No issues so far. But, again, I'm a very light user.
cadamsdotcom 10/14/2025||
Been using pyrefly since July on a big python build.

It has some things it can’t pick up on - no return after a catch block when all code paths are covered for example - but it’s speedy and the error messages are good enough for Claude to understand and ignore or resolve.

Recommended!

natdempk 10/14/2025||
Anyone here know what the ideal/best setup is for typechecking + LSPing Django these days?

I've been leaning on pyright + django-stubs, but wondering if I'm missing something better with fewer gaps and pain points.

kinto 10/14/2025||
(Pyrefly dev here)

We've seen a lot of people have success with the mypy plugin + django-stubs.

Full out-of-the-box support is being actively worked on in Pyrefly: we will have specialized django enum support in the next release and we expect real experimental support by the end of the year. At that time we'll likely post a blog post to announce it [here](https://pyrefly.org/blog/).

nprateem 10/14/2025||
Just started trying ty with django-types. I got the models typed in a day or so. Still wading through the other 200+ errors in my codebase. But it's fast at least.
zelphirkalt 10/14/2025||
Another one I recently discovered and that has a very active maintainer is "zuban" or zuban-ls. It has replaced jedi-language-server for me, and aims to replace mypy as well.
f311a 10/14/2025|
Yeah, there are now 3 competitors and they all written in Rust:

- zuban

- ty (from ruff team)

- pyrefly

One year ago, we had none of them, only slow options.

tialaramex 10/14/2025|||
Speed is one of those "Quantity has a quality all its own" things. We use very fast tools in a qualitatively different way, even though all that changed was how long it takes in seconds.

It is interesting that nobody was writing these tools in C or in C++. There are obvious ergonomic reasons, but perhaps also it matters that Rust cares a lot more about types than either of those languages.

kibwen 10/14/2025|||
> It is interesting that nobody was writing these tools in C or in C++

This one's easier to explain. People interested in tooling for a specific language probably want to write that tooling in that language (hence pip, poetry, mypy, jedi, etc). Normally that would be the end if it, if Python wasn't 10-100x slower than a natively compiled language. And going from Python to Rust is an order of magnitude easier than going from Python to C or Python to C++, because the compiler is so good at identifying silly mistakes. Rust is just a friendlier language.

f311a 10/14/2025|||
It's just very hard to write such systems in C/C++. Even all these Rust versions are segfaulting and panicking quite a lot. So many corner and edge cases that can be found in Python code, and the memory handling is also hard.

The author of Zuban started writing it back in 2020 or 2021, so it took him more than 4 years to complete it. And he is the author of Jedi, so he had prior experience already.

tialaramex 10/14/2025||
I get why they'd panic, but why have enough segfaults that you noticed? So, I went and read the code.

Zuban seems to have a bunch of scary "I'm not sure if this is correct" unsafe blocks, which to me would be a red flag. I mean, it's better that there's a comment expressing the doubt, but my experience is that if you're not sure whether it's correct, it's probably not correct.

estebank 10/14/2025||
While acknowledging the risk of causing a pile-on (which I don't want!), would it be possible to have a link to them or a description of what the unsafe blocks accomplish? I'm intrigued if they are for performance or API ergonomics, if they are due to limitations of the borrow checker, the stdlib or crate dependencies.

For anyone reaching for unsafe, there are in many cases either an existing API (split_at_mut comes to mind). For others, using zero-copy or bytemuck instead of unsafe is a good idea too.

None of that is to say "never write unsafe", unsafe existing is pretty much one of the reasons for Rust to be :)

tialaramex 10/14/2025||
I skimmed these, so this is nothing close to a survey, much less a comprehensive review of the software, however

For example in crates/zuban_python/src/file/diagnostics.rs:

"TODO this unsafe feels very wrong, because a bit lower we might modify the complex/ points."

or crates/zuban_python/src/database.rs:

"Points are guarded by specific logic and if they are overwritten by something that shouldn't it should not be that tragic."

I saw nothing where I was like "ZOMG this is definitely busted" but I definitely did not get the robust "Oh, I see now why this is correct" that I like from a good unsafe rationale comment, and these aren't tiny things like the small unsafe bit twiddling transmutes which are probably either actually correct or in any case will do what you expected at compile time and so any surprises are priced in without a rationale text.

jerrygenser 10/14/2025||||
Basedpyright is not rust but it's a fork of pyright with added features that are otherwise locked in vscode
f311a 10/14/2025|||
It's written in Typescript, which is a super weird choice.
wiseowise 10/14/2025|||
Wasn’t pyright made specifically for VSCode? That would explain TS.
f311a 10/14/2025||
Yes, but why they did not write it in a compiled language? Pyright is pretty slow in large code bases and takes a lot of RAM. Javascript can be faster than python in some cases, but Python is so easily extendable with C,C++, Cython, Rust. They could use Python with one of the compiled language.
IshKebab 10/14/2025||
Because they wanted it to be usable on the web, and I guess WASM wasn't where it is right now when they started.
huflungdung 10/14/2025|||
[dead]
drcongo 10/14/2025||||
It's also horrible for fasle positives unless your project happens to be the exact same setup as the maintainers' - I had to turn off the actual type checking on it. I've since moved wholesale to the Ty alpha and it feels a hell of a lot smarter.
JimDabell 10/14/2025||
It also inherits the unfortunate attitude of Pyright that it will warn against idiomatic Python (EAFP) in favour of non-idiomatic Python (LBYL):

https://github.com/microsoft/pyright/issues/1739

https://docs.python.org/3/glossary.html#term-EAFP

https://docs.python.org/3/glossary.html#term-LBYL

maleldil 10/14/2025|||
Sometimes dynamic Python idioms are incompatible with typed Python. I personally think that's fine, since I consider static typing a significant improvement overall.
JimDabell 10/14/2025||
This isn’t. They actually fixed that bug. Then they changed their minds and backed the fix back out again because they don’t think you should write Python that way:

> I think EAFP is a very unfortunate and ill-advised practice.

They want you to not write the idiomatic Python:

    try:
        foo = bar["baz"]["qux"]
        ...
    except KeyError:
        ...
…and instead write the non-idiomatic version:

    if "baz" in bar and "qux" in bar["baz"]:
        foo = bar["baz"]["qux"]
        ...
    else:
        ...
If this were a linter then I would accept that it is going to be opinionated. But this is not a linter, it’s a type checker. Their opinions about EAFP are irrelevant. That’s idiomatic Python.
IshKebab 10/14/2025||
Well I agree with them. The second code is clearly better. Exceptions should be used for error handling and if those keys are actually optional then you should explicitly check if they exist (or use something like `bar.get("baz")`).
JimDabell 10/15/2025||
You are welcome to that opinion, but type checkers should not be opinionated, especially if they push people to write non-idiomatic Python. If you think this should be written a different way, that’s what lint rules are for.
IshKebab 10/15/2025||
Actually Python type checkers must be opinionated. Python doesn't define the semantics of type annotations so type checkers have to choose them.

They don't always choose the same options, so some Python code may type check in one type checker and not in another.

Yes this is a dumb situation but that's how it is. So Pyright has to make a choice here, and they chose the most sensible option.

You're free to disagree of course.

kstrauser 10/14/2025||||
Eww, what? I hadn’t seen that before. Yikes, I hope the situation’s improved. I’d be butting into that continually.
jon-wood 10/14/2025|||
I'm sorry, I can't take seriously any piece of software which decided to prefix the previous version's name with "based". I'm aware this is a me problem.
wiseowise 10/14/2025|||
Definitely this. I commend author of BPyright, but clown (?) avatar, unknown identity of maintainer, and name of the fork rub me off wrong way.
cruffle_duffle 10/14/2025|||
Hah. I love the name. It implies that whatever the original “pyright” was doing wasn’t keepin’ it real. This new version, it’s “based” so it must be somehow more “real” and “grounded” and “legit”.

All I know is it is much more strict about stuff than pylance was.

Also a me problem!

arccy 10/14/2025|||
it'll be like python package managers and js web frameworks.... a new one every quarter
vovavili 10/14/2025||
uv works so well for the vast majority of scenarios that I don't really see a demand for further innovation in the Python package manager domain.
arccy 10/14/2025|||
yeah we all heard that story every 3 months with all the previous package managers. until there's adoption by an overwhelming majority of projects, it isn't really settled yet.
wiseowise 10/14/2025||
I’ve literally never heard that much buzz and excitement about Python tool before. And I’ve seen them all.

All of them had some big issue that prevented it from getting mainstream. Either it was slow, or didn’t work with existing workflow, or had complex configuration, or something that prevented gradual adoption.

uv is universally praised as the second coming Christ in Python world (and for a good reason). So no, I doubt there will be something else. Not only you need to be better than uv, you also need to have community momentum.

pjmlp 10/15/2025||
Using Python in one form or the other since Python 1.6, there is always some buzz for whatever tool now and then.
insane_dreamer 10/14/2025|||
it still needs to add handling for binaries (the one thing conda can do that uv can't)
rana762 10/14/2025||
[dead]
flanked-evergl 10/14/2025|
Sadly, the question with both this and ty is: Does it support pydantic? If not, then it's not really helpful for many people, and right now AFAIK neither supports pydantic.

Pydantic is probably the problem here, but it is what it is.

ocamoss 10/14/2025||
Pyrefly actually does have (experimental) support for Pydantic! https://pyrefly.org/en/docs/pydantic/
flanked-evergl 10/14/2025||
Nice, did not know.
mixmastamyk 10/14/2025|||
Why would they need to support pydantic when it uses standard annotations? I tried it with ty yesterday and it flagged issues as expected.
flanked-evergl 10/14/2025||
Pydantic does some pretty strange stuff which works as expected but confuses the type checker unless you use the pydantic plugin. https://docs.pydantic.dev/latest/integrations/mypy/
mixmastamyk 10/15/2025||
I see. Tried ty and it seemed to know about missing required args. But wasn't able to follow the Field directives.
phailhaus 10/14/2025||
Python's type system is the problem here, which cannot support even the native dataclass pattern and needs custom plugins written for each type checker.
kstrauser 10/14/2025|||
The type system’s alright. It just gets especially tricky when you’re trying to check code which won’t exist until you run it. For instance, suppose you wanted to load your own module from a database with something like

  foo = eval(result)
It can’t know what you’re going to load until it actually does it.

Things which lean heavily into metaprogramming, typically ORMs or things like Pydantic, fall into that category. I can’t hold that against the type system.

phailhaus 10/14/2025|||
> I can’t hold that against the type system.

I think we should. Dataclasses have existed in Python for an extremely long time, and yet the type system doesn't support defining your own similar classes. Kwargs have also existed forever, but they forgot to support that and had to add TypedDict's much later. And it still doesn't properly support optional fields. There's a lot of stuff like this in the language which are unbelievably frustrating, because for some reason they implemented the syntax before implementing a typechecker. Everything has been hacked in ever since. I consider python's type system to be a lost cause, just hoping for someone to make the Typescript equivalent for Python.

flanked-evergl 10/14/2025||
Dataclasses support optional fields and kwargs perfectly. Not sure what you are talking about.

I don't think you understand what Pydantic brings to the table or why people use it. It has lots more to do with serialization, complex validation and data mapping.

phailhaus 10/16/2025||
kwargs are not dataclasses, they are dicts. TypedDict was shoehorned in later to allow typing dicts, but they are so poorly designed that you can't mark individual fields as optional.
bvrmn 10/15/2025|||
I guess you didn't work with good type system then. Look for TS, for example. How it allows to make strong typing for pydantic-like libraries in FE world. All how it allows to type routers.
flanked-evergl 10/14/2025|||
I don't think this is really true, I think native data classes can do just about everything you need, it's just that you need some tooling around them to get the same as Pydantic offers. I'm pretty sure we are going to see better native dataclass support in Pydantic going forward.

Already there is some support in Pydantic for native dataclasses: https://docs.pydantic.dev/latest/concepts/dataclasses/

phailhaus 10/14/2025|||
There is no facility in the type system to express the idea that "whatever class attributes are defined, those are kwargs to the init function". That's hacked in using extra typechecker plugins. That's why we're sitting around talking about if a particular typechecker "supports pydantic", rather than it just working.
bvrmn 10/15/2025|||
Technically there is dataclass_transform [1]. It's an ungodly hack, I don't know how it passed PEP review. And support by type checkers is questionable. After TS python hints feels like rigid and total unsound mess.

[1]: https://docs.python.org/3/library/typing.html#typing.datacla...

flanked-evergl 10/14/2025|||
There is a way to indicate whatever class attributes are defined, those are kwargs to the init function. For one, you can use `kw_only` on the dataclass decorator [1], alternatively you can use the `kw_only` arg on the field function [2].

[1]: https://docs.python.org/3/library/dataclasses.html#dataclass...

[2]: https://docs.python.org/3/library/dataclasses.html#dataclass...

phailhaus 10/16/2025||
That's only for dataclasses, you can't implement your own class like this without implementing it as a dataclass, because the typechecking for it is hacked in as a custom plugin.

What I'm trying to point out is that these features exist in core Python and yet the type system they built can't express it. By contrast, TypeScript is designed in such a way that you can implement everything yourself without having to write "custom typescript checker plugins".

kitotik 10/14/2025|||
I have used native dataclasses with pydantic starting with v1.5 and it’s only improved with the the newer 2.x releases.

Aside from basic inheritance and complex nested types, the pydantic ‘TypeAdapter’ is awesome for simply validating native dataclasses. It’s a little slow, but everything pydantic is =)