-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Batch is essentially a wrapper around a dict. However, iterating over a batch leads to potentially unexpected behavior.
While list({...}) == list({..}.keys())
, for batch list(Batch(...))
gives a sequence of Batch
objects and list(Batch(...).keys())
gives a list of keys.
This collides with e.g. ruff's recommendation of not using in-dict-keys. I had to disable this rule in #921 because both for b in batch
and for key in batch.keys()
are currently used with their respective semantics throughout the code.
Fixing this would mean defining __iter__
in Batch
to return keys and something like creating a new method in Batch called iter_entries
that would replace the current iteration semantics. This would be a breaking change.
@Trinkle23897 what do you think? One can also live with the current status of the "inconsistency", keep ignoring the ruff recommendation, and just document the current behavior somewhere. I would also add dedicated unit tests in that case
Metadata
Metadata
Assignees
Labels
Type
Projects
Status