googleapis / googleapis/google-cloud-python

`utcnow()` Deprecation Warning

Đang mở
#15,840 1 bình luận 1 reaction 1 người được giao Được @bw-yuhogg nhận Xem trên GitHub
api: datastore
Ngôn ngữ chính
Python
Star
5.4k
Fork
1.8k
Merge trung bình
3 ngày 4 giờ
Pull request đã merge (30 ngày)
122

Mô tả

`_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).
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.