Replace datetime.utcfromtimestamp() with datetime.fromtimestamp(ts, UTC).replace(tzinfo=None)

Proprietary

The datetime.utcfromtimestamp() method is deprecated in Python 3.12. Replace it with datetime.fromtimestamp(ts, UTC).replace(tzinfo=None), importing UTC from datetime where the name is not already in scope. The result is the naive UTC datetime utcfromtimestamp() returned, so it still compares with other naive values.

org.openrewrite.python.migrate.ReplaceDatetimeUtcFromTimestamp
mod run . --recipe=org.openrewrite.python.migrate.ReplaceDatetimeUtcFromTimestamp

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.