uranusjr commented on code in PR #34744:
URL: https://github.com/apache/airflow/pull/34744#discussion_r1345435914
##########
airflow/utils/timezone.py:
##########
@@ -273,3 +274,19 @@ def _format_part(key: str) -> str:
if not joined:
return "<1s"
return joined
+
+
+def parse_timezone(name: str | int):
+ """
+ Parse timezone and return one of the pendulum Timezone.
+
+ Provide the same interface as ``pendulum.tz.timezone(name)``
+
+ .. note::
+ This class for compatibility between pendulum 2 and 3.
+ In pendulum 3 ``pendulum.tz.timezone`` it is a module, which can't be
used as parser
+ In pendulum 2 ``pendulum.timezone`` mypy failed on static check
+
+ :meta: private
+ """
+ return pendulum.timezone(name) # type: ignore[operator]
Review Comment:
The only real difference is the cache; I think in 3.x the cache will exist
in the Timezone constructor instead (matching ZoneInfo’s behaviour in Python
stdlib). Practically though we don’t really hit the cache that often anyway so
the difference is next to none.
##########
airflow/utils/timezone.py:
##########
@@ -273,3 +274,19 @@ def _format_part(key: str) -> str:
if not joined:
return "<1s"
return joined
+
+
+def parse_timezone(name: str | int):
+ """
+ Parse timezone and return one of the pendulum Timezone.
+
+ Provide the same interface as ``pendulum.tz.timezone(name)``
+
+ .. note::
+ This class for compatibility between pendulum 2 and 3.
+ In pendulum 3 ``pendulum.tz.timezone`` it is a module, which can't be
used as parser
+ In pendulum 2 ``pendulum.timezone`` mypy failed on static check
+
+ :meta: private
+ """
+ return pendulum.timezone(name) # type: ignore[operator]
Review Comment:
The only real difference is the cache; I think in 3.x the cache will exist
in the Timezone constructor instead (matching ZoneInfo’s behaviour in Python
stdlib). Practically though we don’t really hit the cache that often anyway so
the difference is next to none.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]