Skip to content

fix(core): wipe() with no arguments should clear all state instead of raising - #840

Closed
eeshsaxena wants to merge 1 commit into
apache:mainfrom
eeshsaxena:fix/wipe-no-args
Closed

fix(core): wipe() with no arguments should clear all state instead of raising#840
eeshsaxena wants to merge 1 commit into
apache:mainfrom
eeshsaxena:fix/wipe-no-args

Conversation

@eeshsaxena

Copy link
Copy Markdown

What

State.wipe() with no arguments should clear all state, but currently raises TypeError.

The docstring says:

If you pass nothing in it will delete the whole thing.

But when both delete and keep are None, the method fell through to the keep branch and evaluated key not in keep with keep=None:

>>> from burr.core.state import State
>>> State({"a": 1, "b": 2}).wipe()
TypeError: argument of type 'NoneType' is not a container or iterable

The delete= and keep= forms were covered by tests, but the documented no-args form was not, so this went unnoticed.

Fix

Handle the three cases explicitly in wipe():

  • delete=[...] -> delete those keys
  • keep=[...] -> delete everything not kept
  • neither -> delete every key (matches the docstring)

Verification

State({"a": 1, "b": 2}).wipe()            # {}
State({"a": 1, "b": 2}).wipe(keep=["a"])   # {"a": 1}
State({"a": 1, "b": 2}).wipe(delete=["a"]) # {"b": 2}

Added test_state_wipe_all alongside the existing wipe tests. tests/core/test_state.py passes (27 passed).

State.wipe() documents that passing neither delete nor keep deletes
everything, but with both None it fell through to a 'key not in keep'
check with keep=None and raised TypeError. Handle the no-args case
explicitly (delete every key) and add a regression test.
@github-actions github-actions Bot added the area/core Application, State, Graph, Actions label Jul 20, 2026
@eeshsaxena

Copy link
Copy Markdown
Author

Closing this to clear out my older open PRs, since it has been sitting a while without review. No hard feelings if it was not a priority. If it is still useful to you, say the word and I will reopen it and rebase it on current main.

@eeshsaxena eeshsaxena closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Application, State, Graph, Actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant