Skip to content

Fixing the return type hint for the transaction method in the standalone client. #3660

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

Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def pipeline(self, transaction=True, shard_hint=None) -> "Pipeline":

def transaction(
self, func: Callable[["Pipeline"], None], *watches, **kwargs
) -> None:
) -> Optional[Union[List[Any], Any]]:
Copy link
Preview

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

The return type hint Optional[Union[List[Any], Any]] can be simplified. Since Any already encompasses List[Any], consider using -> Any or -> Optional[Any]. For stronger typing, introduce a TypeVar for the callback return: e.g.

R = TypeVar('R')
def transaction(self, func: Callable[["Pipeline"], R], *watches, **kwargs) -> Optional[R]:
    ...

Copilot uses AI. Check for mistakes.

"""
Convenience method for executing the callable `func` as a transaction
while watching all keys specified in `watches`. The 'func' callable
Expand Down
Loading