3 ms·
We use Mypy to type check python, and I really like that system. Catches a lot of errors. Not as many as a full static typing system, but still a lot, and you c
by lincolnq 6y ago
We use Mypy to type check python, and I really like that system. Catches a lot of errors. Not as many as a full static typing system, but still a lot, and you can always drop back into dynamic typing when you want.
- _huayra_ 6y agoWow thanks! Does it just insert these checks automatically (`assert type(my_param) == int`)? I remember being so disappointed when I saw PEP484 and realizing that it didn't enforce anything.
- jononor 6y agomypy is only a static checker, there are no runtime-checks inserted. You run it as a command-line tool and it will fail the build if the types do not resolve, like a compiler or linting tool. For runtime-checking based on PEP484 type hints, one can complement this with a library like Pydantic/Enforce.py/typeguard/typesentry. Enforcement of the types is typically opt-in per function call, often by adding a decorator.