diff --git a/valkey/commands/core.py b/valkey/commands/core.py index 93160f9b..4496a12f 100644 --- a/valkey/commands/core.py +++ b/valkey/commands/core.py @@ -8,7 +8,6 @@ AsyncIterator, Awaitable, Callable, - Dict, Iterable, Iterator, List, @@ -24,7 +23,10 @@ from valkey.exceptions import ConnectionError, DataError, NoScriptError, ValkeyError from valkey.typing import ( AbsExpiryT, + AnyEncodableT, AnyKeyT, + AnyFieldT, + AnyStreamIdT, BitfieldOffsetT, ChannelT, CommandsProtocol, @@ -3508,7 +3510,7 @@ def xack(self, name: KeyT, groupname: GroupT, *ids: StreamIdT) -> ResponseT: def xadd( self, name: KeyT, - fields: Dict[FieldT, EncodableT], + fields: Mapping[AnyFieldT, AnyEncodableT], id: StreamIdT = "*", maxlen: Union[int, None] = None, approximate: bool = True, @@ -3933,7 +3935,7 @@ def xrange( def xread( self, - streams: Dict[KeyT, StreamIdT], + streams: Mapping[AnyKeyT, AnyStreamIdT], count: Union[int, None] = None, block: Union[int, None] = None, ) -> ResponseT: @@ -3973,7 +3975,7 @@ def xreadgroup( self, groupname: str, consumername: str, - streams: Dict[KeyT, StreamIdT], + streams: Mapping[AnyKeyT, AnyStreamIdT], count: Union[int, None] = None, block: Union[int, None] = None, noack: bool = False, diff --git a/valkey/typing.py b/valkey/typing.py index 98059061..5c11f283 100644 --- a/valkey/typing.py +++ b/valkey/typing.py @@ -47,6 +47,8 @@ AnyKeyT = TypeVar("AnyKeyT", bytes, str, memoryview) AnyFieldT = TypeVar("AnyFieldT", bytes, str, memoryview) AnyChannelT = TypeVar("AnyChannelT", bytes, str, memoryview) +AnyStreamIdT = TypeVar("AnyStreamIdT", int, bytes, str, memoryview) +AnyEncodableT = TypeVar("AnyEncodableT", int, float, bytes, str, memoryview) ExceptionMappingT = Mapping[str, Union[Type[Exception], Mapping[str, Type[Exception]]]]