3 ms·
I was really happy when I first learned of type annotations being added to Python. However, much of that excitement evaporated when I read that it was just a 'h
by neverartful 6y ago
I was really happy when I first learned of type annotations being added to Python. However, much of that excitement evaporated when I read that it was just a 'hint' and not something that's enforced.
- heavyset_go 6y agoThis was also my initial reaction. However, if you couple type annotations with an LSP server[1] that takes the annotations into consideration[2], you'll get on-the-fly type checking in your editor or IDE. That way you can catch type errors as you write your typed Python code. Besides VS Code, these days lightweight editors like Kate, Sublime Text, Vim, etc can all take advantage of type checking LSP servers for Python. [1] https://github.com/palantir/python-language-server https://github.com/palantir/python-language-server [2] https://github.com/tomv564/pyls-mypy https://github.com/tomv564/pyls-mypy
- photonios 6y agoIt's not enforced by CPython the interpreter. You run mypy to enforce the type hints: http://mypy-lang.org/ http://mypy-lang.org/ It's quite good.
- animatedb 6y agoI like it a lot. Use it with --disallow-untyped-defs to make sure more is caught.