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

Aperta Adatta ai principianti
#1,030 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@alibb007 ci sta già lavorando.

Dal 6/11/2026.

  • #1031 di @alibb007 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
79/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Inizia da burr/core/state.py, in State.wipe() intorno alla riga 440, e leggi come il metodo gestisce delete e keep. Riproduci il problema segnalato con l’esempio nell’issue, poi verifica se ci sono test che coprono wipe() senza argomenti. Il lavoro è terminato quando la chiamata restituisce uno stato vuoto senza generare un TypeError.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

status/needs-triage
What happens

wipe() says that calling it with no arguments deletes the whole state. When both delete and keep are None, the code skips the delete branch and runs [key for key in self._state if key not in keep] with keep=None. Python's in operator raises TypeError on None, so the call fails before anything is deleted. I read this from the code only. I did not run it.

Where

burr/core/state.py:440

To reproduce
from burr.core.state import State

state = State({"a": 1, "b": 2})
assert state.wipe().get_all() == {}
Expected

State({"a": 1, "b": 2}).wipe() returns an empty state.

Actual

Raises TypeError (argument of type 'NoneType' is not iterable), based on the code path above. Not run.

    assert state.wipe().get_all() == {}
           ~~~~~~~~~~^^
  File "/Users/alibb/.ali-hq/work/gh/apache__burr/burr/core/state.py", line 440, in wipe
    fields_to_delete = [key for key in self._state if key not in keep]
                                                      ^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not a container or iterable

Checked on cdea4eb.

Lingua principale
Python
Stelle
2.6k
Fork
218
Merge medio
4g 8h
PR unite (30g)
35

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/burr

Tutte le issue di apache/burr

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.