According to the docstring, the score_cast_func is a callable used to cast the score return value.
However, the zrevrank function only has a withscore parameter and casts to float by default, this discrepancy led to the following code in my project:
x = redis_client.zrevrange(
"test",
0,
-1,
withscores=True,
score_cast_func=int,
)
y = redis_client.zrevrank(
"test",
"test",
withscore=True,
)
y = int(y)
Question
Why does the zrevrange function offer the flexibility of score_cast_func while zrevrank does not? Given the similar nature of these functions, shouldn’t they both support the same score casting logic for consistency?
Proposal
For a more consistent API, I suggest adding the score_cast_func parameter to the zrevrank function, similar to its implementation in zrevrange.
Version
redis 7.2.3
/redis-py 5.0.7
Platform
macOS Sonoma 14.5
Description
Hi everyone, I noticed an inconsistency between the
zrevrange
andzrevrank
functions regarding score casting behavior.The
zrevrange
function has bothwithscore
andscore_cast_func
parameters:According to the docstring, the
score_cast_func
is a callable used to cast the score return value.However, the
zrevrank
function only has awithscore
parameter and casts to float by default, this discrepancy led to the following code in my project:Question Why does the
zrevrange
function offer the flexibility ofscore_cast_func
whilezrevrank
does not? Given the similar nature of these functions, shouldn’t they both support the same score casting logic for consistency?Proposal For a more consistent API, I suggest adding the
score_cast_func
parameter to thezrevrank
function, similar to its implementation inzrevrange
.