googleapis / googleapis/google-cloud-python

`utcnow()` Deprecation Warning

未關閉
#15,840 1 則留言 1 個 reaction 已指派 1 人 已被 @bw-yuhogg 認領 在 GitHub 檢視
api: datastore
主要語言
Python
星號
5.4k
分支
1.8k
平均合併
2 天 23 小時
30 天內合併 PR
123

描述

`_now` staticmethod, used by `auto_now_add`, is using `datetime.datetime.utcnow()`, which is deprecated.

#### Environment details

1. API: python-ndb
2. 2020 MacOSX; Sonama 14.5
3. Python 3.12.4
4. google-cloud-ndb version: 2.16.0

#### Steps to reproduce

1. Add `auto_now_add` to a `DateTimeProperty` model.

#### Code example

```python
time_stamp_field = ndb.DateTimeProperty(tzinfo=datetime.timezone.utc, auto_now_add=True)
```

#### Stack trace
```
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).
```

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。