by raverbashing · 9y ago · 0 comments
Yes, and if I wanted type annotations to stop my program from working I wouldn't be using Python
Enforcing types is exactly what Python IS NOT about. Because of Duck Typing and everything else
So this is not "postmodern error handling" this is "let's code Java in something else and pat ourselves in the back"
Do you want to check errors in "compile time"? Use Pylint. It does the right thing
But for larger projects type checking is valuable. Types introduce additional contracts between components to manage and control the overall complexity of the system.
For small scripts and self contained applications I regard type checking as a burden. For larger projects not.
Pylint is a valuable tool to detect typical errors but does not check types. Regard a function which returns the sum of two given arguments. It will work with both arguments being integers and for both being strings. PyLint will not complain here, but if your code uses this result you might trigger errors much later during progam execution which are hard to detect or understand without type checking.
Wrong solution to the wrong problem. Break that too large for duck typing fucking mess into smaller independent components with well defined and enforced interfaces.
"Well defined and enforced interfaces"? That sounds like a job for static typing!
But seriously, that's exactly what types are good for: defining and enforcing an interface.
Pylint has nothing to do with catching type errors. It catches problems with code style.
I don't find the code in this blog post convincing, but there are reasons to write type-safe code.
No, it does catch type errors, for example accessing methods that are not present in the object
> but there are reasons to write type-safe code.
Yes, and there are lots of languages that allow you that