Fixing the return type hint for the transaction method in the standalone client. by petyaslavova · Pull Request #3660 · redis/redis-py (original) (raw)
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]: ...