Skip to content

Replace datetime.utcnow() with timezone-aware UTC datetimes (Python 3.14 compatibility) #572

@lgelauff

Description

@lgelauff

datetime.datetime.utcnow() is deprecated since Python 3.12 and scheduled for removal in Python 3.14. Running the test suite on Python 3.13 produces 518 deprecation warnings from this call across the codebase.

Affected files (first-party code only):

  • montage/rdb.py — ~25 occurrences
  • montage/mw/__init__.py — 3 occurrences
  • montage/admin_endpoints.py — 1 occurrence
  • montage/public_endpoints.py — 1 occurrence
  • montage/meta_endpoints.py — 1 occurrence

Fix: Replace all occurrences with datetime.datetime.now(datetime.timezone.utc). This is a mechanical substitution — behaviour is identical (UTC timestamps), it's just the new preferred API.

Note: some third-party deps (boltons, clastic, sqlalchemy) also produce this warning. Those are upstream issues and out of scope here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions