googleapis / googleapis/google-cloud-python

`utcnow()` Deprecation Warning

Aperta
#15,840 1 commento 1 reazione 1 assegnatario Rivendicata da @bw-yuhogg Vedi su GitHub
api: datastore
Lingua principale
Python
Stelle
5.4k
Fork
1.8k
Merge medio
3g 4h
PR unite (30g)
122

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.