4 ms·
If you use mypy (as anyone should for any non-hobby Python usage) then Python has one of the strongest type systems available. Optional types, generics, "Any" e
by iooi 5y ago
If you use mypy (as anyone should for any non-hobby Python usage) then Python has one of the strongest type systems available. Optional types, generics, "Any" escape hatches, everything you could want.
- aeturnum 5y agomypy is a great project and I agree that basically every project at scale should use it. However, I think you're wrong about the strength of the Python type system and what a good type system can "get" you. I think mypy both does an amazing job at static checking and that more powerful type systems go far beyond static checks and into changing how you structure and write code. The newly introduced "structural pattern matching" they just introduced[1] is an example of the kind of feature that could be usefully expanded by making type a first-class part of the Python runtime. Again - the dynamism of Python means teams can write amazing extensions to Python (like mypy), but that isn't a replacement for the core team having a plan for how they think typing information should be used at runtime. Their current answer seems to be "nothing," which disappoints me. [1] https://www.python.org/dev/peps/pep-0622/ https://www.python.org/dev/peps/pep-0622/
- yawaramin 5y agoWould mypy have caught any of the issues highlighted in the article?
- Too 5y agoNo. Mypy only cares about types, it would only have been caught if something was expecting tuple of certain length, otherwise not. The problem in the article is more related to syntax, not types, with the problem that both forms are valid syntax with different but still very similar outcome. Pylint on the other hand can find it with implicit-str-concat check enabled.
- jen20 5y ago> one of the strongest type systems available. This is simply not true - Python with mypy isn’t even as strong as Typescript, let alone Rust, F#, Haskell and so forth.