You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using datetime.utcnowis not recommended because different libraries(and datetime itself) often use dates without timezone as local time. And since python v3.12 .utcnow is deprecated.
There are 47 explicit occurrences of `.utcnow` in code
ckan/lib/dictization/model_save.py:54:33: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/lib/uploader.py:159:37: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/lib/uploader.py:266:41: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/logic/action/create.py:702:29: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/logic/action/update.py:310:31: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/model/api_token.py:72:28: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/model/dashboard.py:30:44: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/model/dashboard.py:31:32: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/model/follower.py:34:25: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/model/user.py:34:17: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/model/user.py:349:36: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/model/user.py:352:32: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/cli/test_jobs.py:36:15: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/lib/test_jobs.py:147:15: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/logic/action/test_create.py:659:16: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/logic/action/test_get.py:3041:11: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/logic/action/test_update.py:1289:20: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/logic/action/test_update.py:1302:20: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/logic/action/test_update.py:1315:20: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/logic/action/test_update.py:1328:20: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/logic/action/test_update.py:1343:20: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/logic/action/test_update.py:1355:20: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/logic/action/test_update.py:1370:20: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/logic/action/test_update.py:1383:20: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/model/test_api_token.py:25:18: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/model/test_api_token.py:27:17: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/model/test_user.py:240:23: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/model/test_user.py:246:40: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/model/test_user.py:251:40: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckan/tests/model/test_user.py:256:40: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/activity/email_notifications.py:235:9: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/activity/email_notifications.py:259:37: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/activity/logic/action.py:74:49: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/activity/model/activity.py:64:26: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/activity/tests/logic/test_action.py:27:11: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/activity/tests/logic/test_action.py:724:18: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/activity/tests/logic/test_action.py:745:17: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/activity/tests/logic/test_pagination.py:174:15: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/datapusher/logic/action.py:91:29: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/datapusher/logic/action.py:109:39: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/datapusher/logic/action.py:163:36: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/datapusher/logic/action.py:185:36: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/datapusher/logic/action.py:194:32: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/datapusher/logic/action.py:226:32: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/datapusher/tests/test_action.py:18:29: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/datapusher/tests/test_action.py:202:27: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
ckanext/expire_api_token/plugin.py:55:21: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead
The recommended form is datetime.now(timezone.utc). But it creates a timezone-aware datetime instance. Which causes problems in several places:
All date/timestamp columns in DB are using timestamp-without-timezone type. Even when the code is updated, SQLAlchemy will parse values from DB as datetime instances without a timezone.
Code changes are pretty straightforward. But we need to add a migration for all DB columns to switch them into timezone-aware mode. Which is potentially disruptive change for anyone who relied on dates without timezone.
There is no need to act quickly, as .utcnow only deprecated in python v3.12 and will be available for a number of versions that are not released yet. But we'll have to handle this problem at some point, so making a decision if we are going to change it by CKAN v3.0 or v2.12 is a good start.
The text was updated successfully, but these errors were encountered:
Using
datetime.utcnow
is not recommended because different libraries(anddatetime
itself) often use dates without timezone as local time. And since python v3.12.utcnow
is deprecated.There are 47 explicit occurrences of `.utcnow` in code
The recommended form is
datetime.now(timezone.utc)
. But it creates a timezone-aware datetime instance. Which causes problems in several places:Z
prefix must not be used with timezone offsetCode changes are pretty straightforward. But we need to add a migration for all DB columns to switch them into timezone-aware mode. Which is potentially disruptive change for anyone who relied on dates without timezone.
There is no need to act quickly, as
.utcnow
only deprecated in python v3.12 and will be available for a number of versions that are not released yet. But we'll have to handle this problem at some point, so making a decision if we are going to change it by CKAN v3.0 or v2.12 is a good start.The text was updated successfully, but these errors were encountered: