News for hackers. Stuff that matters.
Re:Ty: A fast Python type checker and LSP by hauntsaninja on Tuesday December 16, 2025 @09:42PM (#46297631)
The conformance test suite is currently mostly focused on “what does an explicit type annotation mean”

A shared spec for this is important because if you write a Python library, you don’t want to have to write a different set of types for each Python type checker

Here are some things the spec has nothing to say about:

Inference

You don’t want to annotate every expression in your program. Type checkers have a lot of leeway here and this makes a huge difference to what it feels like to use a type checker.

For instance, mypy will complain about the following, but pyright will not (because it infers the types of unannotated collections as having Any):

  x = []
  x.append(1)
  x[0] + "oops"
The spec has nothing to say about this.

Diagnostics

The spec has very little to say about what a type checker should do with all the information it has. Should it complain about unreachable code? Should it complain if you did `if foo` instead of `if foo()` because it’s always true? The line between type checker and linter is murky. Decisions here have nothing to do with “what does this annotation mean”, so are mostly out of scope from the spec.

Configuration

This makes a huge difference when adapting huge codebases to different levels of type checking. Also the defaults really matter, which can be tricky when Python type checkers serve so many different audiences.

Other things the spec doesn’t say anything about: error messages quality, editor integration, speed, long tail of UX issues, implementation of new type system features, plugins, type system extensions or special casing

And then of course there are things we would like to spec but haven’t yet!

Re:Ty: A fast Python type checker and LSP by maleldil on Tuesday December 16, 2025 @11:10PM (#46298150)
> but pyright will not (because it infers the types of unannotated collections as having Any)

This is incorrect. pyright will infer the type of x as list[Unknown].

Re:Ty: A fast Python type checker and LSP by hauntsaninja on Wednesday December 17, 2025 @12:53AM (#46298706)
Unknown has the exact same type system semantics as Any.

Unknown is a pyright specific term for inferred Any that is used as the basis for enabling additional diagnostics prohibiting gradual typing.

Notably, this is quite different from TypeScript’s unknown, which is type safe.

Re:Ty: A fast Python type checker and LSP by ErikBjare on Thursday December 18, 2025 @03:55AM (#46310368)
This was confusing me, thanks.
Re:Ty: A fast Python type checker and LSP by xixixao on Wednesday December 17, 2025 @05:13AM (#46300144)
In case you’re not well versed in Python typecheckers, in the mypy vs Pyright example, Pyright can be configured to complain about not annotating the collection (and so both typecheckers will yell at the code as written).

TypeScript takes the same approach in this scenario, and I assume this helps both be fast.

Re:Ty: A fast Python type checker and LSP by solvedd on Wednesday December 17, 2025 @06:36AM (#46300841)
They were "on the Python Typing Council and helped put together the spec, the conformance test suite, etc" so I assume they are an expert on Python typecheckers
Re:Ty: A fast Python type checker and LSP by xixixao on Wednesday December 17, 2025 @03:51PM (#46305342)
I didn’t write it for parent lol. I guess I should be more careful with “you”.
Re:Ty: A fast Python type checker and LSP by jitl on Wednesday December 17, 2025 @02:15PM (#46304139)
TypeScript will use flow typing to determine the type as number[] in this code:

    const x = []
    x.push(1)
    type t = typeof x // number[]