4 ms·
> IMO, a python script should not reach 1500 lines, unit tests would be much better. My take was that Python's lack of static type checking led to the script b
by rualca 6y ago
> IMO, a python script should not reach 1500 lines, unit tests would be much better.
My take was that Python's lack of static type checking led to the script being an unmaintainable mess because it was risky to refactor and gradually made impossible to audit, to the point where around 30% of its code was dead code that no one was able to spot.
Adding type checks was the key to fix that.
This anecdote feels like the norm in Python projects that fail to use static type checks. Without type hints, you are forced to manually check all code paths that directly and indirectly touch the component you need to change in order to reason if a minor change has catastrophic consequences. With static type checks, instead you only need to look at the type declaration or function signature to determine what you and cannot do. I don't understand how some Pythonista still try to pass this off as a feature instead of a fundamental problem.