4 ms·
Are there best practices and tools for using types in Python? I’d like some of the “compile time”/ editor checks in Java, for example, but with more type infer
by melling 5y ago
Are there best practices and tools for using types in Python?
I’d like some of the “compile time”/ editor checks in Java, for example, but with more type inference. Maybe only important classes or functions.
x = 1
y = foo(bar(baz(x)))
If I declare baz() with types, I’d like my editor to warn me if x is the wrong type.
- benttoothpaste 5y agoNot sure about "best" practices, but Pycharm (a popular Python IDE) will warn about the wrong type in such cases.
- aldanor 5y agoShort answer: use mypy
- dragonwriter 5y ago> Are there best practices and tools for using types in Python? Yes. Mypy and Pyright are both quite good tools, and integrations for one or both are available for most editors.