Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: add iter()/aiter() for lazy filter-based key iteration #682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add iter()/aiter() for lazy filter-based key iteration #682
Changes from all commits
6adf547441a51d69dd491bf50de2a3c47c5File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aiter_keys acloses lists, not cursors
High Severity
aiter_keyswraps each page from_iter_keys_by_filterinaclosing, but those pages are lists and have noaclose. After the first page, iteration raisesAttributeError, so a non-empty index cannot be drained. The async helper that owns the Redis cursor is left unclosed.Reviewed by Cursor Bugbot for commit a3c47c5. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion can't fail. Keys are strings, so
is not Noneholds for anything the generator yields, and an empty index would surface as an uncaughtStopIterationrather than a failed assertion.I checked by swapping in an
iter()that drains the whole index into a list before yielding anything. The test still passed, so it can't tell a streaming implementation from an eager one, which is the one property it's named for.What would work is counting
FT.AGGREGATEround trips before the first key arrives.tests/unit/test_bulk_cursor_dedup.pyalready has a_ReplayCursorharness that fakesclient.ft(name), so this can be a hermetic unit test with no server and no fixture. While you're there, the async method has no laziness test at all.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Laziness test cannot detect eager iteration
Low Severity
test_iter_keys_is_lazyonly asserts that the first yielded value is not None. Keys are strings so that always holds, and an implementation that drained the index before yielding would still pass. The test does not verify lazy or streaming behavior.Reviewed by Cursor Bugbot for commit bf50de2. Configure here.