Live data from Hacker News

Ask HN: Which Python type checker should I use?

news.ycombinator.com

41–50 of 83 posts

Re: Ask HN: Which Python type checker should I use?

#41

pyright is state of the art right now thanks to eric. If you use VSCode+Pylance you will feel right at home coming from Rust/TS. just be aware a lot of community packages aren't ready for typed python. if you stick to the good stuff like fastapi and pydantic, you will be fine.

Better than Pycharm?

Re: Ask HN: Which Python type checker should I use?

#42

Earlier quoted context omitted.

I think you are reading far too much into their comment. I agree that their comment could have benefited from some elaboration but the simple act of them expressing their opinion (especially one that is not seen in the rest of the thread, as of my writing this comment) is a "helpful contribution to the debate", in my opinion.

Given no other context, it's not very helpful

Agree. It also seems a direct contravention of the guidance "Please don't post shallow dismissals.... A good critical comment teaches us something. " https://news.ycombinator.com/newsguidelines.html

Re: Ask HN: Which Python type checker should I use?

#44
post #35

Pyright is the Microsoft provided lsp: does anyone else feel uneasy about using this? Especially given the EEE playbook "that we definitely won't do this time" - would love to have a discussion on this if someone could talk me into using it. I just use a combination of black, flake, and mypy. Apparently ruff is quite good as well. For lsp I use Jedi, which actually worked faster on my company's code base than pyright…

How do you imagine that EEE could be applied to a type checker?

Well Pylance is already closed source so basically the plan is:

1. Make a really great type checker.

2. Make it difficult to use in IDEs other than VSCode.

3. Everyone uses VSCode.

I don't care though. Pyright is fantastic and giving it away for free is amazing even if it is part of a plan to push people to VSCode.

Re: Ask HN: Which Python type checker should I use?

#45
Pyright is much much much better than Mypy, and it's easy to use with VSCode. The only reason to use Mypy is if you're adding types to a legacy codebase and don't want to be immediately confronted with a gazillion type errors, because Mypy has "eh whatever" modes and is generally more lax.

If it's new code, Pyright hands down.

Re: Ask HN: Which Python type checker should I use?

#46
post #24

The only useful types to add are Cython 3, otherwise adding more letters with no benefit reduces readability and reminds me of “public static void main”.

Saying it has no benefit is simply arguing in bad faith. It objectively does. Just maybe they’re not worth the trade off for you.

Re: Ask HN: Which Python type checker should I use?

#47

I would not personally use any of them. Typed python in previous workplace was pretty much shitshow, and if starting from scratch instead of untyped codebase it might be worth it, maybe, for some specific cases, but in general combination of bad library typing and bad type checking tools leads to horrible user experience. So going forward my personal projects continue to be ducktyped, and if I care about types, I use…

I have had the misfortune of having to work with untyped Python code. It is completely awful and I cannot imagine anyone genuinely prefers it. Impossible to navigate. Full of trivial type bugs and typos.

Static typing makes Python tolerable.

Re: Ask HN: Which Python type checker should I use?

#48

Pyright is the Microsoft provided lsp: does anyone else feel uneasy about using this? Especially given the EEE playbook "that we definitely won't do this time" - would love to have a discussion on this if someone could talk me into using it. I just use a combination of black, flake, and mypy. Apparently ruff is quite good as well. For lsp I use Jedi, which actually worked faster on my company's code base than pyright…

A slight correction: Pyright is the Microsoft provided _type checker_. Eric had no intention of ever extending it to a full LSP (though it is usually good enough) in fear of Microsoft abandoning it the moment it started to compete with Pylance [1]. Now that Eric has left Microsoft (but still is somehow the main contributor to Pyright) the situation is even stranger to me.

[1] https://github.com/microsoft/pyright/pull/7177#issuecomment-...

(In case you are wondering, I do not have the time to maintain an independent fork and I am not sure how Microsoft would react to one, now that I have heard Eric's concerns.)

Re: Ask HN: Which Python type checker should I use?

#49
post #41

pyright is state of the art right now thanks to eric. If you use VSCode+Pylance you will feel right at home coming from Rust/TS. just be aware a lot of community packages aren't ready for typed python. if you stick to the good stuff like fastapi and pydantic, you will be fine.

Better than Pycharm?

Kind of hard to say. With pylance the type checking will be definitively better in vscode.

But pycharm had a lot going on to make up for it.

Just as a reference I use pycharm mainly but before sending a PR I will rely on vscode to fix typing issues.

Just use what you likes best.

Re: Ask HN: Which Python type checker should I use?

#50
The recent takeover of rye by the guys doing ruff[1] has some likelihood of rendering the python typing and packaging scene into something more coherent.

Having the tool get started with Ronacher, of Flask fame, gives it some mindshare among those paying attention.

It would be better still if the PSF were endorsing, but that gets too political, I suppose.

[1] https://astral.sh/blog/uv

Post reply on HN