Hacker News new | ask | show | jobs
by Tijdreiziger 2962 days ago
Python 3.6 introduced type checking as an option, so you can hack something together in Python, then add types later.
2 comments

Type hints aren't checked or enforced by the compiler. They're really just special-syntax comments to help the developer (or IDE, as the case may be). I wouldn't call this "type checking".
You can run a type-checking tool (e.g. mypy) which will tell you if you've made any type errors.

Since Python has no 'compile' step, type-checking takes the place of compiling in other languages.

I'm using the type annotations from `typing` in a Python 3.5 project I'm working on, but only as a form of documentation. Unfortunately mypy doesn't work for me – the project heavily uses a namedtuple-style sum type library, and I haven't found a way to make the types it generates work with mypy.

(iirc mypy has builtin support for namedtuple, but doesn't really support other types generated at runtime)