Skip to content

Conversation

petyaslavova
Copy link
Collaborator

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

This change is adding score_cast_func argument to the commands that had with_score/s argument - this way all commands expose consistent pattern how to handle the responses.

Another change added here is adding the usage of the configured score_cast_func for RESP3 responses as well - with the current code this argument value was completely ignored for resp3 responses.

Fixes #3300

@petyaslavova petyaslavova requested a review from Copilot October 9, 2025 12:08
@petyaslavova petyaslavova added the breakingchange API or Breaking Change label Oct 9, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 adds consistency to Redis sorted set commands by adding the score_cast_func parameter to zrank, zrevrank, and zunion commands, aligning them with other sorted set operations. It also ensures that score_cast_func is properly applied to both RESP2 and RESP3 protocol responses.

  • Adds score_cast_func parameter to zrank, zrevrank, and zunion commands for consistency
  • Introduces new parser helper functions to handle score casting for rank operations in both RESP2 and RESP3
  • Updates test cases to verify the new functionality works correctly with custom score cast functions

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
redis/commands/core.py Adds score_cast_func parameter to zrank, zrevrank, and zunion methods
redis/_parsers/helpers.py Introduces new parser functions for handling score casting in rank operations for both RESP protocols
tests/test_commands.py Adds comprehensive test coverage for the new score_cast_func parameter functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@elena-kolevska elena-kolevska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits

@petyaslavova petyaslavova force-pushed the ps_add_score_cast_func_to_methods_with_withscores_arg branch from 2e86cfc to 914de46 Compare October 17, 2025 08:03
@petyaslavova petyaslavova merged commit 5ee081d into master Oct 21, 2025
74 of 75 checks passed
@petyaslavova petyaslavova deleted the ps_add_score_cast_func_to_methods_with_withscores_arg branch October 21, 2025 10:35
petyaslavova added a commit that referenced this pull request Oct 21, 2025
…onsistency with the other sorted sets commands (#3795)

* Adding score_cast_func argument to zrank, zrevrank and zunion - for consistency with the other sorted sets commands

* Adding async tests; Add docstrings info for the new arg; removed unused option

* Applying review comments

* Try to fix the failing tests with Python 3.9 - it looks like a new dep version problem

* Restricting some lib versions for tests with PyPy Python - with newer versions we have hanging multiprocessing tests

* Restricting all test deps to specific versions for PyPy tests

* Skipping multiprocessing tests with PyPY Python due to unstable behavior - sometimes processes hang and cause action timeouts. Enabling all long running pipeline jobs to be started after the initial fast checks.

* Restricting lib requirements for Python 3.9 and fix an pubsub flaky test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breakingchange API or Breaking Change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent withscore and score_cast_func Parameters Between zrevrange and zrevrank

2 participants