Skip to content

fix: state.wipe() with no arguments raises TypeError instead of - #1031

Open
alibb007 wants to merge 2 commits into
apache:mainfrom
alibb007:fix/state-wipe-with-no-arguments-raises
Open

alibb007 wants to merge 2 commits into
apache:mainfrom
alibb007:fix/state-wipe-with-no-arguments-raises

Conversation

@alibb007

@alibb007 alibb007 commented Nov 6, 2026

Copy link
Copy Markdown

Fixes #1030.

State.wipe() called with no arguments now clears all keys, as the docs say, instead of raising TypeError on key not in None.

The script in the issue fails before this change and passes after it.

@github-actions github-actions Bot added the area/core Application, State, Graph, Actions label Nov 6, 2026

@YongGoose YongGoose left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this against main (36e3ff3) in a Linux container with Python 3.12.

  • State({"a": 1, "b": 2}).wipe() raises TypeError: argument of type 'NoneType' is not iterable on main and returns {} with this change. wipe(keep=[...]), wipe(delete=[...]) and empty lists for either behave the same as before.
  • tests/core/test_state.py: 26 passed.

Two things before merging:

  1. The typing import in burr/core/state.py was rewrapped, which isn't part of the fix. Both black 23.11.0 and isort 5.12.0 with the settings in .pre-commit-config.yaml put it back on one line, so the pre-commit job will fail once CI runs here. Reverting that hunk is enough.
  2. There is no test for the no-argument case. Something next to test_state_wipe_delete / test_state_wipe_keep would cover it:
def test_state_wipe_all():
    state = State({"foo": "bar", "baz": "qux"})
    wiped = state.wipe()
    assert wiped.get_all() == {}

@alibb007

Copy link
Copy Markdown
Author

Thanks for checking this.

  1. Put the typing import in burr/core/state.py back on one line. That drops the hunk from the diff.
  2. Added test_state_wipe_all to tests/core/test_state.py next to the other two wipe tests. It uses the test you suggested.

This branch has not been deployed

No deployments
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.

State.wipe() with no arguments raises TypeError instead of clearing state

2 participants