A Python dict that can report which keys you did not use
9 months ago
- #Python
- #Unit Testing
- #TrackingDict
- TrackingDict is a Python dictionary subclass that tracks accessed keys.
- It helps ensure all data retrieved is either tested or used in reports.
- Example use case: Verifying which dictionary keys are accessed in a report.
- Includes properties `accessed_keys` and `never_accessed_keys` for tracking.
- Typed version provided with TypeVar and type hints for better type safety.
- Potential issues: Does not track `.get()` method calls by default.
- Key lookup misses (KeyError) are also added to `_accessed_keys`.