"I forgot to implement that method."

This sentence has caused production bugs.

Python's ABCs (Abstract Base Classes) prevent this.

Now any storage backend must implement these methods. 

Forget one? Python tells you at instantiation, so you'll catch it in time:

class InMemoryRepo(SnippetRepository):
def add(self, snippet):
...
# Forgot list()? → TypeError immediately

This is a *contract*: your code can't lie about what it supports.

--
Prefer static analysis over runtime checks? `typing.Protocol` defines the same contract but is enforced by type checkers (mypy, ty) rather than at instantiation. ABCs catch errors when you run the code; Protocols catch them before you run anything. 📈
--

Tomorrow's free LIVE session covers how to structure real Python projects using these patterns.

#Python #CleanCode #SoftwareEngineering #ABCs

The 2026 Python Stack: A Free Live Session