Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datetime.utcnow() deprecation #10

Merged
merged 2 commits into from Oct 27, 2023
Merged

datetime.utcnow() deprecation #10

merged 2 commits into from Oct 27, 2023

Conversation

edsu
Copy link
Contributor

@edsu edsu commented Oct 19, 2023

I noticed some warnings popping up during testing a library under python v3.12 that depends on sqlite_migrate and figured I'd send along the small change.

tests/test_sqlite_migrate.py: 4 warnings
tests/test_sqlite_utils_migrate_command.py: 9 warnings
  /Users/edsummers/.local/share/virtualenvs/sqlite-migrate-kmlAZzTv/lib/python3.12/site-packages/sqlite_migrate/__init__.py:80: 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).
    "applied_at": str(datetime.datetime.utcnow()),

Thanks for a useful module, and for the sqlite-utils/datasette ecosystem!

I noticed some warnings popping up during testing a library under python
v3.12 that depends on sqlite_migrate and figured I'd send along the
small change.

```
tests/test_sqlite_migrate.py: 4 warnings
tests/test_sqlite_utils_migrate_command.py: 9 warnings
  /Users/edsummers/.local/share/virtualenvs/sqlite-migrate-kmlAZzTv/lib/python3.12/site-packages/sqlite_migrate/__init__.py:80: 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).
    "applied_at": str(datetime.datetime.utcnow()),
```

Thanks for a useful module, and for the sqlite-utils/datasette ecosystem!
@simonw
Copy link
Owner

simonw commented Oct 27, 2023

Thanks for this!

@simonw
Copy link
Owner

simonw commented Oct 27, 2023

Tests fail in 3.8 and 3.9 because datetime.UTC is a more recent thing.

I'll try datetime.timezone.utc.

@simonw simonw merged commit 6a203e7 into simonw:main Oct 27, 2023
5 checks passed
simonw added a commit that referenced this pull request Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants