Skip to content

Commit 25d1480

Browse files
committed
fix: support ipv6 in client host param
1 parent 07d7097 commit 25d1480

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

influxdb_client_3/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
PointSettings
1111
from influxdb_client_3.write_client.domain.write_precision import WritePrecision
1212

13+
from ipaddress import IPv6Address, AddressValueError
14+
1315
polars = importlib.util.find_spec("polars") is not None
1416

1517

@@ -147,6 +149,12 @@ def __init__(
147149
hostname = parsed_url.hostname if parsed_url.hostname else host
148150
port = parsed_url.port if parsed_url.port else 443
149151

152+
try:
153+
IPv6Address(hostname)
154+
hostname = f"[{hostname}]"
155+
except AddressValueError:
156+
pass
157+
150158
# Construct the clients using the parsed values
151159
if write_port_overwrite is not None:
152160
port = write_port_overwrite

0 commit comments

Comments
 (0)