Taragolis commented on code in PR #34744:
URL: https://github.com/apache/airflow/pull/34744#discussion_r1345428641


##########
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:
   I've also think about this first, however there is also exists differences 
exists around `pendulum.tz.timezone.Timezone`. Maybe because of the different 
implementation of this class, 2.1.2 custom implementation around tzinfo, 3.0 
(beta) custom implementation around zoneinfo.Zoneinfo
   
   [master 
version](https://github.com/sdispater/pendulum/blob/master/src/pendulum/__init__.py#L77-L87)
   ```python
   def timezone(name: str | int) -> Timezone | FixedTimezone:
       """
       Return a Timezone instance given its name.
       """
       if isinstance(name, int):
           return fixed_timezone(name)
   
       if name.lower() == "utc":
           return UTC
   
       return Timezone(name)
   ```
   
   [Current version 
(2.1.2)](https://github.com/sdispater/pendulum/blob/d9aa101fe76852b75cba14d686ede923641c5b4d/pendulum/tz/__init__.py#L24-L40)
   ```python
   def timezone(name, extended=True):  # type: (Union[str, int], bool) -> 
_Timezone
       """
       Return a Timezone instance given its name.
       """
       if isinstance(name, int):
           return fixed_timezone(name)
   
       if name.lower() == "utc":
           return UTC
   
       if name in _tz_cache:
           return _tz_cache[name]
   
       tz = _Timezone(name, extended=extended)
       _tz_cache[name] = tz
   
       return tz
   ```
   



-- 
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]

Reply via email to