Update Type Hints for List Command Parameters from str to KeyT#3848
Merged
petyaslavova merged 4 commits intomasterfrom Nov 17, 2025
Merged
Update Type Hints for List Command Parameters from str to KeyT#3848petyaslavova merged 4 commits intomasterfrom
petyaslavova merged 4 commits intomasterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates type hints for list command parameters in redis/commands/core.py from str to KeyT (which is defined as Union[bytes, str, memoryview]), enabling these commands to accept byte strings and memoryview objects in addition to regular strings. The changes affect 17 list commands including operations like push, pop, range, and position queries.
- Updates parameter types from
strtoKeyTfor all major list commands - Adds test coverage for byte keys and memoryview keys
- Fixes issue #3199
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| redis/commands/core.py | Updated type hints from str to KeyT for 17 list command methods (lindex, linsert, llen, lpop, lpush, lpushx, lrange, lrem, lset, ltrim, rpop, rpoplpush, rpush, rpushx, lpos, sort, brpoplpush) to enable support for bytes and memoryview key types |
| tests/test_commands.py | Added test coverage for byte keys and memoryview keys with list commands, including two new test methods and an inline test for lrange with byte keys |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
vladvildanov
approved these changes
Nov 17, 2025
petyaslavova
added a commit
that referenced
this pull request
Nov 18, 2025
* Extending the typehints for list names from just strings to KeyT * Update tests/test_commands.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Skipping new test on cluster - some commands contain multi-node keys --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
petyaslavova
added a commit
that referenced
this pull request
Nov 19, 2025
* Extending the typehints for list names from just strings to KeyT * Update tests/test_commands.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Skipping new test on cluster - some commands contain multi-node keys --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR updates type hints across all list command methods in redis/commands/core.py to accept
KeyTinstead of str for list name parameters, enabling support for byte strings and memoryview objects.The changes affect 17 list commands including
lindex,linsert,llen,lpop,lpush,lpushx,lrange,lrem,lset,ltrim,rpop,rpoplpush,rpush,rpushx,lpos,sort, andbrpoplpush.Comprehensive test coverage has been added to validate all commands work correctly with byte keys and memoryview objects.
Fixes #3199