Skip to content

The state of python type checking and the future of basedpyright

TL;DR

Basedpyright is now in maintenance mode.

  • I won't be adding any new features or accepting any contributions that add new features
  • I will still merge upstream pyright releases for the forseeable future, until it becomes too much of a hassle for me to do so
  • I will still accept simple bug fixes, and will try to fix any critical issues that arise

This post details why I've made this decision, and what my personal recommendations are for basedpyright users.

History and context

When I first forked pyright almost 3 years ago, it was out of frustration due to years of working in a codebase that used mypy as its type checker. If you were working with Python at the time, there was simply no way to reliably configure your IDE to show the same errors as the type checker you were using in your CI.

Mypy just didn't have a language server, so most users just relied on the type checking and built into VSCode or Pycharm, which disagreed with mypy in many cases.

Then I learnt about pyright, which supposedly had a language server. Unfortunately, it was deliberately handicapped by Microsoft, who locked most of its features behind their proprietary Pylance VSCode extension.

In practice this meant pyright had the exact same problem as mypy: the type checker in the IDE was different to the one in your CI. in fact Pyright for some reason never even had an official PyPI package, so users had to install NodeJS/NPM, tools that are only relevant for a completely different language, just to be able to properly set up type checking in their project.

These issues, plus the many others that I raised which got rejected, were my primary motivation for forking pyright in the first place. It wasn't a decision I made lightly because I knew it'd be something I'd feel obligated to maintain for the forseeable future, which is why I tried to collaborate with the maintainer first, which obviously didn't work out.

Why I'm making this decision

Upstream maintenance

Eric Traut, the primary maintainer of Pyright, left Microsoft a few years ago. While he continued to maintain Pyright for a while after he left, his contributions eventually died down. Pylance maintainers eventually took over and now the project is primarily maintained using LLMs, and with less focus on type checking features.

In my opinion this has made Pyright much slower and less stable as of recent releases, and much more difficult to merge.

AI

I understand that this is the norm for many projects nowadays, but as I said in my previous post, what AI has done to programming has significantly impacted my motivation to work on open source projects. I no longer find it fun to review PRs from contributors. In fact I kinda no longer really enjoy interacting with other developers at all.

There are better alternatives now

I wouldn't be making this post if those were the only two reasons -- I'd suck it up and keep working on basedpyright the same as I always have.

The main reason is simply that basedpyright is no longer the only option for users who want a decent type checker and language server for python, and as of very recently, I believe it's no longer the best option either.

As I mentioned above, I created basedpyright because the existing options were unusable to me. But nowadays there are actually viable alternatives that address the problems I had with both mypy and pyright:

Both of these tools solve all of those problems, plus more that I could never realistically accomplish myself. They are significantly faster than mypy and pyright, and they are both maintained by teams who are very receptive to user feedback.

I've been very active in the issue trackers for both projects and am very happy with how receptive they are to feedback from their users, and glad to say that they've taken inspiration from basedpyright (for example both ty and pyrefly have implemented their own baseline feature).

My recommendation

Full disclosure: the pyrefly team reached out to me a few months ago for my feedback. I hung out with them at Pycon and I've been in contact with them since. They have been quick to address most of the issues I've raised.

That said, I've tried to be as unbiased as possible when deciding which type checker to use for my projects going forward and more importantly, which one to recommend to others.

Both pyrefly and ty are still in development, but as of right now, my recommendation is to use pyrefly.

I came to this conclusion after comparing the rules between them along with every issue I encountered. As of writing this, more of the rules covered by basedpyright are covered by pyrefly than ty, and there are a few missing features in ty that make it not really feasible to use yet in real projects, such as this one.

That said, I'm still very excited for ty, since they seem to be improving Python's type system by going above and beyond the typing spec (eg. with ty_extensions).