Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Both mypy and pyright will do that.

This still makes me seethe. We have pip, poetry, conda, and more. The Python folks knew that multiple incompatible systems would arise from a grammar spec without a behavior spec. And here we are. Python doesn't do anything useful with the types, but third-parties are left to their own devices.



> The Python folks knew that multiple incompatible systems would arise from a grammar spec without a behavior spec.

Python typecheckers predate in-language annotations and drove the spec, not vice versa.


Function annotations were added as part of Python 3.0, with PEP 3107, proposed in 2006 [0]. The first public mypy commit was in 2012 [1], and originally it was using C++-style syntax (`list<Token> lex(str s):`). The `typing` module and the official use of function annotation for type hints came in 2014 with PEP 484 [2], inspired by mypy. The first pyright commit was in 2019 (with a lot of code in the third commit [3], possibly moved from the VSCode extension).

[0] https://peps.python.org/pep-3107/

[1] https://github.com/python/mypy/commit/6f0826a9c169c4f05bb893...

[2] https://peps.python.org/pep-0484/

[3] https://github.com/microsoft/pyright/commit/1d91744b1f268fd0...


I agree. I believe the type checker should've been part of the interpreter, or a module like pip. Differences between mypy and pyright drive me crazy.

That said, I don't think this a reason not to use type hints. They're still useful (see TFA), even if they're not perfect.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: