patrickdesjardins.com
My Thoughts on Python (2025) - Patrick Desjardins Blog
# 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件
Async/await complexity and blocking event loop anti-patterns
6Developers frequently block event loops with sync I/O calls (e.g., using `requests` instead of `aiohttp`), throttling async performance. Missing `await` keywords cause runtime exceptions rather than compile-time hints.
Weak type hints provide insufficient runtime safety guarantees
6Type hints (introduced 2015) serve as documentation and IDE hints but don't prevent runtime errors. Changing function return types still compiles fine, failing only at runtime. Async function typing misses missing `await` calls.
Test failures from broken dependencies overshadow assertion errors
6Unit tests fail during setup (broken dependencies, missing object properties) rather than at assertions. PyTest cannot run tests after dependency refactoring, delaying detection of actual logic bugs.
Project complexity balloons quickly with scripting-style codebases
5Python scripts written without discipline grow unwieldy and difficult to maintain. Historic cross-implementation compatibility breaks regularly, causing pain. Refactoring becomes risky without strong static analysis.