Skip to content

Commit a786c39

Browse files
authored
import get_localzone_name only if timezone not avaiable
get_localzone_name was added in tzlocal 4.0 and not available in older version. Move the import to provide a workaround using older version of tzlocal
1 parent 0ea6420 commit a786c39

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

trino/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
from requests import Response
7272
from requests import Session
7373
from requests.structures import CaseInsensitiveDict
74-
from tzlocal import get_localzone_name # type: ignore
7574

7675
import trino.logging
7776
from trino import constants
@@ -184,9 +183,12 @@ def __init__(
184183
self._extra_credential = extra_credential
185184
self._client_tags = client_tags.copy() if client_tags is not None else list()
186185
self._roles = self._format_roles(roles) if roles is not None else {}
187-
self._timezone = timezone or get_localzone_name()
188186
if timezone: # Check timezone validity
189187
ZoneInfo(timezone)
188+
self._timezone = timezone
189+
else:
190+
from tzlocal import get_localzone_name
191+
self._timezone = get_localzone_name()
190192
self._encoding = encoding
191193

192194
@property

0 commit comments

Comments
 (0)