6 ms·
I can't decide if it's a feature or a bug that there are at least 3 major type checkers for Python.
by threadweaver34 4y ago
I can't decide if it's a feature or a bug that there are at least 3 major type checkers for Python.
- nine_k 4y agoIt's a consequence of Python never having been designed as a language with a static type system. In fact, Python is utterly dynamic and has a number of mechanisms that allow to write code which defies and mocks any attempts at static typing. When the pain of maintaining larger codebases resulted in attempts to add static type checking (ultimately successful), it was, and still is, impossible to produce a solution that would work equally well for all kinds of codebases. Stricter tools show too many "false positives", laxer tools miss too many cases that a real static type checker would flag. Say, things that Django does (not to mention Zope) can only be described well by special-casing them. Hence different tools which strike different kinds of compromises.
- amarshall 4y ago> It's a consequence of Python never having been designed as a language with a static type system Is it? Mypy is semi-official and has Guido as a contributor. It also predates both pyright and pyre by many years. Honestly I find it somewhat sad that huge tech companies create their own instead of contributing to an existing and popular implementation. But perhaps the internal versions predated Mypy by a lot.
- Mehdi2277 4y agoPyright is pretty recent and started development years after mypy. But some of pyright's design goals (laziness for LSP) would have made it very difficult to do in mypy without a very large refactor/rewrite. Pyright is implemented in typescript for better LSP/vscode integration and performance. pytype (google's type checker) is only one I know that predates mypy for when it started development. Pyre's reason is interesting, https://github.com/facebook/pyre-check/issues/38 https://github.com/facebook/pyre-check/issues/38. Pyre is based off of Hack, facebook's php compiler. Facebook made pyre to re-use tooling/techniques from Hack on python. Secondary reason is performance. Pyre is done in OCaml and having same performance in type checker implemented within python is hard.