From 2c8f4e4bf61b75c573d46197d75f4ea384e28628 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 5 Oct 2023 23:18:55 +0400 Subject: [PATCH 1/2] Fix _TYPE_HOSTS to require covariant Sequence (#2325) (cherry picked from commit c5c4df43d2e9dc236d9d25872009b4ec2fd82360) --- elasticsearch/_sync/client/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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] = [] From c541953639f39bba209ba498b90d43c49c1f333e Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 6 Oct 2023 00:07:21 +0400 Subject: [PATCH 2/2] Trigger CI