-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Update Type Hints for List Command Parameters from str to KeyT #3848
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
Update Type Hints for List Command Parameters from str to KeyT #3848
Conversation
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.
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 <[email protected]>
* Extending the typehints for list names from just strings to KeyT * Update tests/test_commands.py Co-authored-by: Copilot <[email protected]> * Skipping new test on cluster - some commands contain multi-node keys --------- Co-authored-by: Copilot <[email protected]>
* Extending the typehints for list names from just strings to KeyT * Update tests/test_commands.py Co-authored-by: Copilot <[email protected]> * Skipping new test on cluster - some commands contain multi-node keys --------- Co-authored-by: Copilot <[email protected]>
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