eeshsaxena opened a new pull request, #840:
URL: https://github.com/apache/burr/pull/840

   ## 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`:
   
   ```python
   >>> 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
   
   ```python
   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).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to