|
|
|
|
|
by kortex
1398 days ago
|
|
> If at some point you decide the way one of those sub-libraries works is wrong, could be done better, etc. then you can write a new sub-library that just provides the same public interface. That's...that's literally how type systems and interfaces work. You do know Python supports behavioral subtyping (Protocol), right? It sounds like you certainly have had some bad experiences with poorly-written typed python. But that speaks more to those maintainers not knowing how to actually use types effectively, vs a shortcoming of static typing in python. Python's type system has plenty of shortcomings, but has plenty of escape hatches as well. |
|
What you get with typing and interfaces is that all the code has an interface. Small sections of code have a large badly-defined interface.
The main reason people are using typing in Python is to support large Monorepos. Because everything is typed in them, all the code in the repository depends on all the other code in a spaghete dependency graph.
This results in the following issues:
* Small code changes lead to hour long unit test runs since most of the unit tests need to be rerun for every change.
* It's impossible to update the Python version since all the Python code needs to be updated at the same time.
* Long check-in times for changes running MyPy over 100k lines of code.
* Maintainability issues since code can't be updated without knock on effects all over the codebase.
Okay, so what are the benefits of using types in Python:
* On average MyPy type checking will catch 1 bug per developer per year, which wouldn't of being caught normally.
* It makes people who previously coded in statically typed languages feel more familar with the code.
Basically, if you look at the Pros vs Cons, you should ditch the typing checking. It's a net negative to the codebase.