Skip to content

Fix DeprecationWarning creating naive datetime #1023

@jacobg

Description

@jacobg

The following line of code:

return datetime.datetime.utcnow()

produces this error:

  /Users/j/.pyenv/versions/3.12.9/envs/n/lib/python3.12/site-packages/google/cloud/ndb/model.py:3900: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    return datetime.datetime.utcnow()

There are some other lines of code that do the same thing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: datastoreIssues related to the googleapis/python-ndb API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions