Replace datetime.utcnow() with datetime.now(UTC).replace(tzinfo=None)

Proprietary

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

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

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