diff --git a/elasticsearch/_sync/client/utils.py b/elasticsearch/_sync/client/utils.py index f778b35a9..97e92df1d 100644 --- a/elasticsearch/_sync/client/utils.py +++ b/elasticsearch/_sync/client/utils.py @@ -30,6 +30,7 @@ List, Mapping, Optional, + Sequence, Set, Tuple, Type, @@ -69,7 +70,9 @@ # Default User-Agent used by the client USER_AGENT = create_user_agent("elasticsearch-py", __versionstr__) -_TYPE_HOSTS = Union[str, List[Union[str, Mapping[str, Union[str, int]], NodeConfig]]] +_TYPE_HOSTS = Union[ + str, Sequence[Union[str, Mapping[str, Union[str, int]], NodeConfig]] +] _TYPE_ASYNC_SNIFF_CALLBACK = Callable[ [AsyncTransport, SniffOptions], Awaitable[List[NodeConfig]] @@ -139,7 +142,7 @@ def hosts_to_node_configs(hosts: _TYPE_HOSTS) -> List[NodeConfig]: """Transforms the many formats of 'hosts' into NodeConfigs""" # To make the logic here simpler we reroute everything to be List[X] - if not isinstance(hosts, (tuple, list)): + if isinstance(hosts, str): return hosts_to_node_configs([hosts]) node_configs: List[NodeConfig] = []