Skip to content
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

Redis.json().objlen returns type list instead of int #2960

Closed
trkwyk opened this issue Sep 22, 2023 · 2 comments · Fixed by #2966
Closed

Redis.json().objlen returns type list instead of int #2960

trkwyk opened this issue Sep 22, 2023 · 2 comments · Fixed by #2966
Labels
maintenance Maintenance (CI, Releases, etc)

Comments

@trkwyk
Copy link
Contributor

trkwyk commented Sep 22, 2023

Version: redis-stack-server:7.2.0-v2 via docker; redis-py 5.0.0

Platform: macOS

Description: Redis.json().objlen returns type list instead of int. The typing hint suggests it should return int instead of list. In redis-cli, it does return int though.

@sjpotter
Copy link
Contributor

per the documentation, it returns an array.

https://redis.io/commands/json.objlen/#examples

JSON.OBJLEN returns an array of integer replies for each path specified as the number of keys in the object or nil, if the matching JSON value is not an object.

the type hint should probably be fixed.

@trkwyk
Copy link
Contributor Author

trkwyk commented Sep 27, 2023

per the documentation, it returns an array.

https://redis.io/commands/json.objlen/#examples

JSON.OBJLEN returns an array of integer replies for each path specified as the number of keys in the object or nil, if the matching JSON value is not an object.

the type hint should probably be fixed.

Sorry my bad, objlen of redis-cli indeed returns list but the type hint is left unchanged in 5.0.1. I've just tested the 5.0.1 api and it still returns list.

def objlen(self, name: str, path: Optional[str] = Path.root_path()) -> int:

@trkwyk trkwyk mentioned this issue Sep 27, 2023
6 tasks
@dvora-h dvora-h added the maintenance Maintenance (CI, Releases, etc) label Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Maintenance (CI, Releases, etc)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants