Skip to content

Commit 2c8f4e4

Browse files
pquentingithub-actions[bot]
authored andcommitted
Fix _TYPE_HOSTS to require covariant Sequence (#2325)
(cherry picked from commit c5c4df4)
1 parent 8317976 commit 2c8f4e4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

elasticsearch/_sync/client/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
List,
3131
Mapping,
3232
Optional,
33+
Sequence,
3334
Set,
3435
Tuple,
3536
Type,
@@ -69,7 +70,9 @@
6970
# Default User-Agent used by the client
7071
USER_AGENT = create_user_agent("elasticsearch-py", __versionstr__)
7172

72-
_TYPE_HOSTS = Union[str, List[Union[str, Mapping[str, Union[str, int]], NodeConfig]]]
73+
_TYPE_HOSTS = Union[
74+
str, Sequence[Union[str, Mapping[str, Union[str, int]], NodeConfig]]
75+
]
7376

7477
_TYPE_ASYNC_SNIFF_CALLBACK = Callable[
7578
[AsyncTransport, SniffOptions], Awaitable[List[NodeConfig]]
@@ -139,7 +142,7 @@ def hosts_to_node_configs(hosts: _TYPE_HOSTS) -> List[NodeConfig]:
139142
"""Transforms the many formats of 'hosts' into NodeConfigs"""
140143

141144
# To make the logic here simpler we reroute everything to be List[X]
142-
if not isinstance(hosts, (tuple, list)):
145+
if isinstance(hosts, str):
143146
return hosts_to_node_configs([hosts])
144147

145148
node_configs: List[NodeConfig] = []

0 commit comments

Comments
 (0)