Skip to content

Support scoped enable and disable context managers - #250

Open
jackwalkerlabs wants to merge 1 commit into
gruns:masterfrom
jackwalkerlabs:feat/enable-disable-context-125
Open

jackwalkerlabs wants to merge 1 commit into
gruns:masterfrom
jackwalkerlabs:feat/enable-disable-context-125

Conversation

@jackwalkerlabs

Copy link
Copy Markdown

ic.enable() and ic.disable() now support with blocks that restore the previous enabled state on exit. Ordinary calls still change the state immediately. Nested blocks and exceptions restore the enclosing state, and the README shows the scoped usage.

Fixes #125, following the proposed return-a-context-manager approach in the discussion.

Validation: all 68 unittest tests pass on Python 3.12/macOS; Mypy checks all five source files. The three new tests fail on the original implementation and cover both initial states, nesting, and exception propagation.

Implemented and tested using Codex under the submitting account's authorization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Add enable/disable as contextmanager

1 participant