Skip to content

Commit 3c1e9d5

Browse files
Upgrade to Python 3.12 (#1252)
1 parent 903b312 commit 3c1e9d5

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Set up Python
2121
uses: actions/setup-python@v5
2222
with:
23-
python-version: 3.9
23+
python-version: 3.12
2424
cache: 'pip'
2525
cache-dependency-path: '**/requirements*.txt'
2626
- name: Install dependencies
@@ -67,7 +67,7 @@ jobs:
6767
- name: Set up Python
6868
uses: actions/setup-python@v5
6969
with:
70-
python-version: 3.9
70+
python-version: 3.12
7171
cache: 'pip'
7272
cache-dependency-path: '**/requirements*.txt'
7373
- name: Install dependencies

demos/blog/aiohttpdemo_blog/db.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from datetime import datetime
1+
from datetime import datetime, UTC
2+
from functools import partial
23

3-
from sqlalchemy import ForeignKey, String
4+
from sqlalchemy import DateTime, ForeignKey, String
45
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
56
from sqlalchemy.orm import (
67
DeclarativeBase,
@@ -36,7 +37,8 @@ class Posts(Base):
3637

3738
id: Mapped[int] = mapped_column(primary_key=True)
3839
body: Mapped[str] = mapped_column(String(140))
39-
timestamp: Mapped[datetime] = mapped_column(index=True, default=datetime.utcnow)
40+
timestamp: Mapped[datetime] = mapped_column(DateTime(timezone=True), index=True,
41+
default=partial(datetime.now, UTC))
4042

4143
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"))
4244
user: Mapped[Users] = relationship(back_populates="posts", lazy="raise_on_sql")

demos/motortwit/motortwit/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,5 @@ async def add_message(self, request):
180180
'email': user['email'],
181181
'username': user['username'],
182182
'text': form['text'],
183-
'pub_date': datetime.datetime.utcnow()})
183+
'pub_date': datetime.datetime.now(datetime.UTC)})
184184
return redirect(request, 'timeline')

0 commit comments

Comments
 (0)