Live data from Hacker News

Ty: A fast Python type checker and language server

github.com

101–110 of 296 posts

Re: Ty: A fast Python type checker and language server

#101
post #3
post #2

Just compared the time to check on a fairly large project: - mypy (warm cache) 18s - ty: 0.5s (and found 3500 errors) They've done it again.

Great, but how does it compare to Pyright on the utility / performance curve? Pyright is mature and already very fast. https://github.com/microsoft/pyright

[dead]

Re: Ty: A fast Python type checker and language server

#102
post #3
post #2

Just compared the time to check on a fairly large project: - mypy (warm cache) 18s - ty: 0.5s (and found 3500 errors) They've done it again.

Great, but how does it compare to Pyright on the utility / performance curve? Pyright is mature and already very fast. https://github.com/microsoft/pyright

in my experience pyright is unable to infer many inherited object types (compared to PyCharm's type inference)

Re: Ty: A fast Python type checker and language server

#103
post #76
post #3

Earlier quoted context omitted.

Great, but how does it compare to Pyright on the utility / performance curve? Pyright is mature and already very fast. https://github.com/microsoft/pyright

Pyright is only for type-checking and it lacks many features you'd expected from a modern LSP (I forgot which). Hence, it was forked and someone created basedpyright to fix it: https://github.com/DetachHead/basedpyright

To extend on this:

In python it's pretty common to have LSP separate from type checking separate from linting (e.g. ruff+mypy+ide_specific_lsp).

Which to be fair sucks (as it limits what the LSP can do, can lead to confusing mismatches in error/no-error and on one recent project I had issues with the default LSP run by vscode starting to fall apart and failing to propose auto imports for some trivial things for part of the project....)

But it's the stack where pyright fits in.

Re: Ty: A fast Python type checker and language server

#104
post #73

Earlier quoted context omitted.

how does it compare against mypy? is it much faster?

In the same folder: time uvx mypy . Result: uvx mypy . 0.46s user 0.09s system 74% cpu 0.740 total So ty is about 7x faster - but remember ty is still in development and may not catch the same errors / report false errors, so it's not a fair comparison yet.

Note that `uvx mypy` may give you inaccurate timings on macOS. The antivirus in macOS goes a little crazy the first time it executes a mypyc compiled program.

Re: Ty: A fast Python type checker and language server

#105
post #96
post #85

Looks good but it has the same issues that i have with mypy. Packages that don't include the type hints blow-up my process. In mypy i've come to terms with strategically ignoring packages or finding a package of type hints. Mypy is runs cleanly on my project but I get >800 errors with TY, mostly things like: lint:unresolved-import: Cannot resolve imported module `pydantic` --> vartia/usr_id.py:4:6 | 2 | from typing i…

The current version can handle importing pydantic without error just fine, but it probably can't find your virtualenv, so it doesn't know what third-party dependencies you have installed. Ty will discover your venv if it is in `.venv` in the project directory; otherwise you can help it out with the `--python` CLI flag.

We'll also discover your venv if you: - Activate it manually (`source .venv/bin/activate`, etc.) - Set the `VIRTUAL_ENV` environment variable - Or use a command such as `uv run` or the equivalent from pdm/poetry/hatch to run ty (these project managers usually implicitly set the `VIRTUAL_ENV` variable to point to the project's virtual environment before executing any commands)

Re: Ty: A fast Python type checker and language server

#106

Recently I started a python project and I wanted to do it the "proper" way. mypy + pylint. But even on this small 15-20kloc program these tools are way to slow to do anything in realtime. It takes double digit seconds to have feedback. Way to long for an LSP. I'm honestly appalled the state of affairs is this bad. What the hell do people do with moderately or even large sized code bases?

[dead]

Re: Ty: A fast Python type checker and language server

#108

Fingers crossed this is/becomes extensible. Pyright and MyPy both suffer from lack of extensibility IMO (Pyright doesn't consider the use case and MyPy plugins come across as an afterthought with limited capabilities). There are many things that can be built on the back of type-checked AST.

Charlie already said in a podcast ( https://www.youtube.com/watch?v=XVwpL_cAvrw ) that they are not looking to make it extensible. That it's considered a feature that type checking works interchangeably across tools and projects. Ruff's linting and formatting is more likely to get plugin/extension support at some point in the future.

not specific to just your answer but why do people mention ruff?

Ruff is a linter which (intentionally) does close to no type checking.

So you pretty much have to pair it up with a type check to get any even just half way decent static code analysis.

Re: Ty: A fast Python type checker and language server

#109
post #71
post #44

Curious why so many people want to implement type checkers for python? What problems are being solved that aren't covered already?

Speed.

That's a big part of it, but there are also several areas where we're trying to innovate on functionality as well as speed. I'd personally be pretty disappointed if the only thing we had to offer at the end of all this was a type checker where the only value add was speed. We've also got first-class support for intersection types, and quite a different model to other type checkers regarding when and whether redefinitions are allowed, for example. We believe there are significant areas where typing can be made more usable and easily adoptable than it is today.

Re: Ty: A fast Python type checker and language server

#110
prior to astral appearing, python's tooling has been beyond terrible, compared to say, Java's

astral have now replaced the awful pip with the fantastic uv

various awful linters with with the fantastic ruff

and now hopefully replacing the terrible type checkers (e.g. mypy) with a good one!

I hope they have the pypi backend on their list too, my kingdom for Maven Central in python!

Post reply on HN