Back

patrickdesjardins.com

My Thoughts on Python (2025) - Patrick Desjardins Blog

1/31/2025Updated 2/7/2026
https://patrickdesjardins.com/blog/my-thoughts-on-python-2025

# Typing Is Very Weak Python introduced types in 2015 in Python 3.5. During my assignments I never used them. Mostly because we had the requirement to use Python 2. As I developed more and more features in my project, I forgot exactly which type of parameters or variables I needed and added types. Now, the whole code is fully typed. Still, I have many runtime issues. Coming from a similar experience where JavaScript wasn't typed and TypeScript added type I was surprised to see that typing the code does not provide much defense against bad code. Python's type is mainly a documentation and helps the code editor. … Fortunately, I have several unit tests that mitigate most of the issues. However, the problem with testing was that the tests were failing not because of assertion but because the PyTest tool couldn't run the tests in some situations because of the refactoring of broken dependencies. In other cases, the unit tests would fail before hitting the assertion because a function received a wrong object and properties were missing. Another pitfall with type is asynchronous functions. Missing an `await` generates an exception instead of automatically giving the developer a hint that this does not work. In the end, the problem is that once it works, it works but nothing prevents someone from modifying the return of a function and still having the code looking fine until at runtime it fails. While unit tests might mitigate some issues, there are many scenarios where it continues to be precarious. Going back to the change of the return type, the unit tests of the modified function might fail and will require changes but every place where the code invokes the function is now failing. … # Conclusion Overall, the typing situation looks problematic as a project grows, especially if you have not written a part (or don't remember). The project is only about 7,000 lines of code, and I feel some pain and hesitation when refactoring. With a stronger typing system, moving files from one folder to another would let the code editor manage the reference automatically.

Related Pain Points4