Reuse and Composition¶
Goals¶
- Balance reuse with readability.
- Avoid unnecessary layers.
Guidance¶
- Prefer thin wrappers and composition.
- Use existing extension points before inventing new ones.
- Preserve error context; avoid double serialization.
Example¶
Use requests' auth hook instead of duplicating request logic:
class AuthBase:
"""Base class that all auth implementations derive from"""
def __call__(self, r):
raise NotImplementedError("Auth hooks must be callable.")