Repository: redis/redis-py
Pull request: Fix objlen type hint
## 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)?
- [ ] Was the change added to CHANGES file?

_NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open._

### Description of change

_Please provide a description of the change here._

closes #2960 


Problem statement:
Redis.json().objlen returns type list instead of int
**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.

Hints from issue discussion:
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.
> 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.
https://github.com/redis/redis-py/blob/cc4bc1a544d1030aec1696baef2861064fa8dd1c/redis/commands/json/commands.py#L124

Commit message: Fix objlen type hint

Patch to review:
diff --git a/redis/commands/json/commands.py b/redis/commands/json/commands.py
index 0f92e0d6c9..6cfe5844c3 100644
--- a/redis/commands/json/commands.py
+++ b/redis/commands/json/commands.py
@@ -121,7 +121,7 @@ def objkeys(
         """  # noqa
         return self.execute_command("JSON.OBJKEYS", name, str(path))
 
-    def objlen(self, name: str, path: Optional[str] = Path.root_path()) -> int:
+    def objlen(self, name: str, path: Optional[str] = Path.root_path()) -> List[Union[int, None]]:
         """Return the length of the dictionary JSON value under ``path`` at key
         ``name``.
 


Code review comments:
diff_hunk: @@ -121,7 +121,7 @@ def objkeys(
         """  # noqa
         return self.execute_command("JSON.OBJKEYS", name, str(path))
 
-    def objlen(self, name: str, path: Optional[str] = Path.root_path()) -> int:
+    def objlen(self, name: str, path: Optional[str] = Path.root_path()) -> List[Union[int, None]]:
path: redis/commands/json/commands.py
text: @user1:
```suggestion
    def objlen(self, name: str, path: Optional[str] = Path.root_path()) -> List[Optional[int]]:
```

@author:
Hello I was just copying the type hint of the return value of `arrlen` and it seems several other methods in https://github.com/redis/redis-py/blob/5391c5fc39a2c9aaa1b2e5acc799b93444270b88/redis/commands/json/commands.py use `List[Union[int, None]]` so is it better to keep it in line? Well of course you have the final say. If you insist `List[Optional[int]]` I'll commit.

@user1:
@author Yes, `List[Optional[int]]` is better, we need to change in `arrlen`