Skip to content

Commit 8f15e66

Browse files
committed
Drop Python 3.9 support
1 parent 7ab1bc5 commit 8f15e66

File tree

5 files changed

+66
-68
lines changed

5 files changed

+66
-68
lines changed

.github/workflows/build.yml

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ name: Build
33
on: [push, pull_request]
44

55
jobs:
6-
76
test:
87
runs-on: ubuntu-latest
98
strategy:
109
matrix:
11-
python_version: [3.9, '3.10', '3.11', '3.12', '3.13']
10+
python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
1211

1312
services:
1413
mongo:
@@ -17,60 +16,60 @@ jobs:
1716
- 27017:27017
1817

1918
steps:
20-
- uses: actions/checkout@v4
21-
- name: Set up Python
22-
uses: actions/setup-python@v5
23-
with:
24-
python-version: ${{ matrix.python_version }}
25-
- name: Install dependencies
26-
run: |
27-
python -m pip install --upgrade pip
28-
pip install hatch
29-
hatch env create
30-
- name: Lint and typecheck
31-
run: |
32-
hatch run lint-check
33-
- name: Test
34-
run: |
35-
hatch run test-cov-xml
36-
- uses: codecov/codecov-action@v5
37-
with:
38-
token: ${{ secrets.CODECOV_TOKEN }}
39-
fail_ci_if_error: true
40-
verbose: true
41-
- name: Build and install it on system host
42-
run: |
43-
hatch build
44-
pip install dist/fastapi_users_db_beanie-*.whl
45-
python test_build.py
19+
- uses: actions/checkout@v4
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python_version }}
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install hatch
28+
hatch env create
29+
- name: Lint and typecheck
30+
run: |
31+
hatch run lint-check
32+
- name: Test
33+
run: |
34+
hatch run test-cov-xml
35+
- uses: codecov/codecov-action@v5
36+
with:
37+
token: ${{ secrets.CODECOV_TOKEN }}
38+
fail_ci_if_error: true
39+
verbose: true
40+
- name: Build and install it on system host
41+
run: |
42+
hatch build
43+
pip install dist/fastapi_users_db_beanie-*.whl
44+
python test_build.py
4645
4746
release:
4847
runs-on: ubuntu-latest
4948
needs: test
5049
if: startsWith(github.ref, 'refs/tags/')
5150

5251
steps:
53-
- uses: actions/checkout@v4
54-
- name: Set up Python
55-
uses: actions/setup-python@v5
56-
with:
57-
python-version: 3.9
58-
- name: Install dependencies
59-
shell: bash
60-
run: |
61-
python -m pip install --upgrade pip
62-
pip install hatch
63-
- name: Build and publish on PyPI
64-
env:
65-
HATCH_INDEX_USER: ${{ secrets.HATCH_INDEX_USER }}
66-
HATCH_INDEX_AUTH: ${{ secrets.HATCH_INDEX_AUTH }}
67-
run: |
68-
hatch build
69-
hatch publish
70-
- name: Create release
71-
uses: ncipollo/release-action@v1
72-
with:
73-
draft: true
74-
body: ${{ github.event.head_commit.message }}
75-
artifacts: dist/*.whl,dist/*.tar.gz
76-
token: ${{ secrets.GITHUB_TOKEN }}
52+
- uses: actions/checkout@v4
53+
- name: Set up Python
54+
uses: actions/setup-python@v5
55+
with:
56+
python-version: "3.10"
57+
- name: Install dependencies
58+
shell: bash
59+
run: |
60+
python -m pip install --upgrade pip
61+
pip install hatch
62+
- name: Build and publish on PyPI
63+
env:
64+
HATCH_INDEX_USER: ${{ secrets.HATCH_INDEX_USER }}
65+
HATCH_INDEX_AUTH: ${{ secrets.HATCH_INDEX_AUTH }}
66+
run: |
67+
hatch build
68+
hatch publish
69+
- name: Create release
70+
uses: ncipollo/release-action@v1
71+
with:
72+
draft: true
73+
body: ${{ github.event.head_commit.message }}
74+
artifacts: dist/*.whl,dist/*.tar.gz
75+
token: ${{ secrets.GITHUB_TOKEN }}

fastapi_users_db_beanie/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""FastAPI Users database adapter for Beanie."""
22

3-
from typing import Any, Generic, Optional, TypeVar
3+
from typing import Any, Generic, TypeVar
44

55
import bson.errors
66
from beanie import Document, PydanticObjectId
@@ -46,8 +46,8 @@ class BaseOAuthAccount(BaseModel):
4646
access_token: str
4747
account_id: str
4848
account_email: str
49-
expires_at: Optional[int] = None
50-
refresh_token: Optional[str] = None
49+
expires_at: int | None = None
50+
refresh_token: str | None = None
5151

5252

5353
class BeanieUserDatabase(
@@ -63,16 +63,16 @@ class BeanieUserDatabase(
6363
def __init__(
6464
self,
6565
user_model: type[UP_BEANIE],
66-
oauth_account_model: Optional[type[BaseOAuthAccount]] = None,
66+
oauth_account_model: type[BaseOAuthAccount] | None = None,
6767
):
6868
self.user_model = user_model
6969
self.oauth_account_model = oauth_account_model
7070

71-
async def get(self, id: ID) -> Optional[UP_BEANIE]:
71+
async def get(self, id: ID) -> UP_BEANIE | None:
7272
"""Get a single user by id."""
7373
return await self.user_model.get(id) # type: ignore
7474

75-
async def get_by_email(self, email: str) -> Optional[UP_BEANIE]:
75+
async def get_by_email(self, email: str) -> UP_BEANIE | None:
7676
"""Get a single user by email."""
7777
return await self.user_model.find_one(
7878
self.user_model.email == email,
@@ -81,7 +81,7 @@ async def get_by_email(self, email: str) -> Optional[UP_BEANIE]:
8181

8282
async def get_by_oauth_account(
8383
self, oauth: str, account_id: str
84-
) -> Optional[UP_BEANIE]:
84+
) -> UP_BEANIE | None:
8585
"""Get a single user by OAuth account id."""
8686
if self.oauth_account_model is None:
8787
raise NotImplementedError()

fastapi_users_db_beanie/access_token.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from typing import (
33
Any,
44
Generic,
5-
Optional,
65
TypeVar,
76
)
87

@@ -39,8 +38,8 @@ def __init__(self, access_token_model: type[AP_BEANIE]):
3938
self.access_token_model = access_token_model
4039

4140
async def get_by_token(
42-
self, token: str, max_age: Optional[datetime] = None
43-
) -> Optional[AP_BEANIE]:
41+
self, token: str, max_age: datetime | None = None
42+
) -> AP_BEANIE | None:
4443
query: dict[str, Any] = {"token": token}
4544
if max_age is not None:
4645
query["created_at"] = {"$gte": max_age}

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ asyncio_default_fixture_loop_scope = "function"
44
addopts = "--ignore=test_build.py"
55

66
[tool.ruff]
7-
target-version = "py39"
7+
target-version = "py310"
88

99
[tool.ruff.lint]
1010
extend-select = ["I", "UP"]
@@ -75,17 +75,17 @@ classifiers = [
7575
"Framework :: FastAPI",
7676
"Framework :: AsyncIO",
7777
"Intended Audience :: Developers",
78-
"Programming Language :: Python :: 3.9",
7978
"Programming Language :: Python :: 3.10",
8079
"Programming Language :: Python :: 3.11",
8180
"Programming Language :: Python :: 3.12",
8281
"Programming Language :: Python :: 3.13",
82+
"Programming Language :: Python :: 3.14",
8383
"Programming Language :: Python :: 3 :: Only",
8484
"Topic :: Internet :: WWW/HTTP :: Session",
8585
]
86-
requires-python = ">=3.9"
86+
requires-python = ">=3.10"
8787
dependencies = [
88-
"fastapi-users >= 10.0.1",
88+
"fastapi-users >= 15.0.1",
8989
"beanie >=1.11.0,<2.0.0",
9090
]
9191

tests/test_fastapi_users_db_beanie.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import AsyncGenerator
2-
from typing import Any, Optional
2+
from typing import Any
33

44
import pymongo.errors
55
import pytest
@@ -18,7 +18,7 @@
1818

1919

2020
class User(Document, BeanieBaseUser):
21-
first_name: Optional[str] = None
21+
first_name: str | None = None
2222

2323

2424
class OAuthAccount(BaseOAuthAccount):

0 commit comments

Comments
 (0)