uranusjr commented on code in PR #34683:
URL: https://github.com/apache/airflow/pull/34683#discussion_r1345349552


##########
airflow/serialization/serializers/timezone.py:
##########
@@ -17,17 +17,32 @@
 # under the License.
 from __future__ import annotations
 
-from typing import TYPE_CHECKING
+import datetime
+import sys
+from typing import TYPE_CHECKING, cast
 
 from airflow.utils.module_loading import qualname
 
+PY39 = sys.version_info >= (3, 9)
+
 if TYPE_CHECKING:
     from pendulum.tz.timezone import Timezone
 
     from airflow.serialization.serde import U
 
 
-serializers = ["pendulum.tz.timezone.FixedTimezone", 
"pendulum.tz.timezone.Timezone"]
+serializers = [
+    "pendulum.tz.timezone.FixedTimezone",
+    "pendulum.tz.timezone.Timezone",
+]
+
+if PY39:
+    serializers.append("zoneinfo.ZoneInfo")
+    from zoneinfo import ZoneInfo
+else:
+    serializers.append("backports.zoneinfo.ZoneInfo")
+    from backports.zoneinfo import ZoneInfo

Review Comment:
   Technically you can have `backports.zoneinfo` on 3.9+ and I can imagine 
scenarios where a library installs it for some compatibility edge case. It 
might not be a bad idea to include the backports serializer unconditionally 
instead.
   
   I think we should import both `ZoneInfo` classes lazily as well. `import 
zoneinfo` pulls in timezone data from the system, which can be quite slow 
depending on the setup.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to