Tom Ritchford
1 min readNov 25, 2023


But you don't give any reasons why this should actually be a principle.

Having worked on multiple codebases where people took this as gospel for almost every part of the code, I would say that this added little in value to the codebase but added friction to every commit and every attempt to read the code.

In C++, Java and other compiled languages, there is a very good use for dependency inversion - to allow you to test individual components in isolation. There's really no other way to do it.

But Python has excellent mocking facilities: there is almost never a need for DI for testing.

Which is why in twenty years of writing Python I have yet to work on any project that used it.

If you are going to use DI, at least avoid putting it in everywhere routinely. Don't do it until you need it.

The whole SOLID idea is very inconsistent. Lyskov substitution is so fundamental that a codebase that doesn't respect everywhere it is just wrong. On the other hand, open-closed is simply a guideline which you have to break all the time during development because you can't move forward without adding some method to a base interface, or changing existing behavior.

Good article in general, have some claps!