From 175e81be7fbcf26dbf38d5ff6930f4c202cdfbe1 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Fri, 22 Jul 2022 10:57:15 +0300 Subject: [PATCH] Improve `redis.utils` types (#8362) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Alex Waygood --- stubs/redis/redis/utils.pyi | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/stubs/redis/redis/utils.pyi b/stubs/redis/redis/utils.pyi index 5180003bf..09f261095 100644 --- a/stubs/redis/redis/utils.pyi +++ b/stubs/redis/redis/utils.pyi @@ -1,3 +1,4 @@ +from collections.abc import Iterable, Mapping from contextlib import AbstractContextManager from typing import Any, TypeVar, overload from typing_extensions import Literal @@ -14,11 +15,8 @@ def from_url(url: str, *, db: int = ..., decode_responses: Literal[True], **kwar @overload def from_url(url: str, *, db: int = ..., decode_responses: Literal[False] = ..., **kwargs: Any) -> Redis[bytes]: ... def pipeline(redis_obj: Redis[_StrType]) -> AbstractContextManager[Pipeline[_StrType]]: ... -@overload -def str_if_bytes(value: bytes) -> str: ... # type: ignore[misc] -@overload -def str_if_bytes(value: _T) -> _T: ... +def str_if_bytes(value: str | bytes) -> str: ... def safe_str(value: object) -> str: ... -def dict_merge(*dicts): ... -def list_keys_to_dict(key_list, callback): ... -def merge_result(command, res): ... +def dict_merge(*dicts: Mapping[str, _T]) -> dict[str, _T]: ... +def list_keys_to_dict(key_list, callback): ... # unused, alias for `dict.fromkeys` +def merge_result(command: object, res: Mapping[Any, Iterable[_T]]) -> list[_T]: ...