tirkarthi opened a new issue, #32344: URL: https://github.com/apache/airflow/issues/32344
### Apache Airflow version 2.6.2 ### What happened The usage of `datetime.utcnow` is deprecated in Python 3.12 and it can be replaced with `airflow.utils.timezone.utcnow` and a similar method can be introduced for utcfromtimestamp too in timezone module > [datetime.datetime](https://docs.python.org/3.12/library/datetime.html#datetime.datetime)’s [utcnow()](https://docs.python.org/3.12/library/datetime.html#datetime.datetime.utcnow) and [utcfromtimestamp()](https://docs.python.org/3.12/library/datetime.html#datetime.datetime.utcfromtimestamp) are deprecated and will be removed in a future version. Instead, use timezone-aware objects to represent datetimes in UTC: respectively, call [now()](https://docs.python.org/3.12/library/datetime.html#datetime.datetime.now) and [fromtimestamp()](https://docs.python.org/3.12/library/datetime.html#datetime.datetime.fromtimestamp) with the tz parameter set to [datetime.UTC](https://docs.python.org/3.12/library/datetime.html#datetime.UTC). (Contributed by Paul Ganssle in [gh-103857](https://github.com/python/cpython/issues/103857).) ### What you think should happen instead _No response_ ### How to reproduce ``` ./python Python 3.13.0a0 (heads/main:58906213cc, Jul 3 2023, 21:54:53) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import datetime >>> datetime.datetime.utcnow() <stdin>:1: DeprecationWarning: datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.now(datetime.UTC). datetime.datetime(2023, 7, 4, 12, 41, 45, 658447) >>> datetime.datetime.utcfromtimestamp(10000) <stdin>:1: DeprecationWarning: datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.fromtimestamp(timestamp, datetime.UTC). datetime.datetime(1970, 1, 1, 2, 46, 40) ``` ### Operating System Ubuntu ### Versions of Apache Airflow Providers _No response_ ### Deployment Virtualenv installation ### Deployment details _No response_ ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md) -- 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]
