3 ms·
Check out typeguard: https://github.com/agronholm/typeguard https://github.com/agronholm/typeguard it offers run-time type checking in a variety of ways, is i
by Dowwie 9y ago
Check out typeguard: https://github.com/agronholm/typeguard https://github.com/agronholm/typeguard
it offers run-time type checking in a variety of ways, is intuitive, and actively maintained
- StavrosK 9y agoIs static checking with mypy just as good, faster and more timely?
- rcthompson 9y agoThey're not mutually exclusive. Static type checking is fine if you can cover all your code with it, but it doesn't enforce anything at runtime. If you're writing a library that will be called by other people's code (which likely won't be statically type-checked), it might still be useful to validate your functions' inputs at runtime.
- StavrosK 9y agoTrue, and I guess it helps for when your non-validated code calls validated code. Odd how we've come around to realizing the importance of types and contracts after years of dynamic typing. It's a bit like document databases, people are starting to realize again how convenient relational databases and how helpful schemas are.
- rcthompson 9y agoTo be a little more clear, in a language where static typing was mandatory, there would obviously be no need for dynamic type checking of those same types. But since Python's static typing is optional, dynamic type checking at runtime is not redundant.