Spectate (v1.0.1) is a Python library designed to track changes to mutable data types, providing undo/redo capabilities for operations on objects like dictionaries and lists. It achieves this by wrapping functions that modify tracked objects, recording events for each change. The library is currently feature-complete and in maintenance mode, with a slow release cadence.
pip install spectateVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `spectate.track` to observe changes to a dictionary, and then `undo` and `redo` those changes. The `@track` decorator wraps the `add_entry` function, automatically recording each modification to the dictionary `a`.
Access event data using standard dictionary key notation (e.g., `event['key']`) instead of attribute access (e.g., `event.key`).
Remove any direct imports or references to `spectate.utils.Immutable`. If you were creating custom immutable objects, you'll need to refactor to use standard Python dicts or create your own immutable wrappers.
Ensure `spectate.events.rollback()` is called with the `undo` parameter, e.g., `spectate.events.rollback(undo_action_function)`.
No dependency data recorded yet.