Check ten standard-library contracts around scoped state, grouping, mutation, and shutdown.
Review the cases
- Python ContextVar tokens: restore nested request state exactly
- Python itertools.groupby: contiguous runs are not global groups
- Python bounded deque: append silently evicts the opposite end
- Python dataclass InitVar: validate and derive state without storing input
- Python SQLite row factories: reject duplicate output names before mapping
- Python QueueListener: stop the logging worker after queued records drain
- Python threading.Barrier: abort a failed phase so peers do not wait forever
- Python decimal localcontext: keep a rounding rule inside one calculation
- Python bisect key: search with a key value, insert with a record
- Python lru_cache: callers share the same cached mutable result
Common Mistakes
Passing a local contract does not test a concurrent production workload.
