Use TypeAlias where possible for type aliases (#7630)

This commit is contained in:
Alex Waygood
2022-04-16 02:01:00 +01:00
committed by GitHub
parent c0e6dd3f3f
commit 740193a8fc
218 changed files with 760 additions and 625 deletions
+5 -5
View File
@@ -3,15 +3,15 @@ from _typeshed import Self, SupportsItems
from datetime import datetime, timedelta
from types import TracebackType
from typing import Any, Callable, ClassVar, Generic, Iterable, Iterator, Mapping, Pattern, Sequence, TypeVar, overload
from typing_extensions import Literal
from typing_extensions import Literal, TypeAlias
from .commands import CoreCommands, RedisModuleCommands, SentinelCommands
from .connection import ConnectionPool, _ConnectionPoolOptions
from .lock import Lock
from .retry import Retry
_Value = bytes | float | int | str
_Key = str | bytes
_Value: TypeAlias = bytes | float | int | str
_Key: TypeAlias = str | bytes
# Lib returns str or bytes depending on value of decode_responses
_StrType = TypeVar("_StrType", bound=str | bytes)
@@ -21,9 +21,9 @@ _T = TypeVar("_T")
_ScoreCastFuncReturn = TypeVar("_ScoreCastFuncReturn")
# Keyword arguments that are passed to Redis.parse_response().
_ParseResponseOptions = Any
_ParseResponseOptions: TypeAlias = Any
# Keyword arguments that are passed to Redis.execute_command().
_CommandOptions = _ConnectionPoolOptions | _ParseResponseOptions
_CommandOptions: TypeAlias = _ConnectionPoolOptions | _ParseResponseOptions
SYM_EMPTY: bytes
EMPTY_RESPONSE: str
@@ -1,12 +1,12 @@
from collections.abc import Mapping
from typing import Any
from typing_extensions import Literal
from typing_extensions import Literal, TypeAlias
from .aggregation import AggregateRequest, AggregateResult, Cursor
from .query import Query
from .result import Result
_QueryParams = Mapping[str, str | float]
_QueryParams: TypeAlias = Mapping[str, str | float]
NUMERIC: Literal["NUMERIC"]