Skip to content

Commit 2ab49e1

Browse files
committed
Minor improvements
1 parent 947f790 commit 2ab49e1

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<em>Ready-to-use and customizable users management for FastAPI</em>
99
</p>
1010

11-
[![build](https://github.com/fastapi-users/fastapi-users-db-dynamodb/workflows/Build/badge.svg)](https://github.com/fastapi-users/fastapi-users/actions)
12-
[![codecov](https://codecov.io/gh/fastapi-users/fastapi-users-db-dynamodb/branch/master/graph/badge.svg)](https://codecov.io/gh/fastapi-users/fastapi-users-db-dynamodb)
11+
[![build](https://github.com/AppSolves/fastapi-users-db-dynamodb/workflows/Build/badge.svg)](https://github.com/fastapi-users/fastapi-users/actions)
12+
[![codecov](https://codecov.io/gh/AppSolves/fastapi-users-db-dynamodb/branch/master/graph/badge.svg)](https://codecov.io/gh/AppSolves/fastapi-users-db-dynamodb)
1313
[![PyPI version](https://badge.fury.io/py/fastapi-users-db-dynamodb.svg)](https://badge.fury.io/py/fastapi-users-db-dynamodb)
1414
[![Downloads](https://pepy.tech/badge/fastapi-users-db-dynamodb)](https://pepy.tech/project/fastapi-users-db-dynamodb)
1515

fastapi_users_db_dynamodb/access_token.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ def __init__(
6161
self._resource = dynamodb_resource
6262

6363
@asynccontextmanager
64-
async def _table(self):
64+
async def _table(self, table_name: str):
6565
"""Async context manager that yields a Table object."""
6666
if self._resource is not None:
67-
table = await self._resource.Table(self.table_name)
67+
table = await self._resource.Table(table_name)
6868
yield table
6969
else:
7070
async with self.session.resource("dynamodb") as dynamodb:
71-
table = await dynamodb.Table(self.table_name)
71+
table = await dynamodb.Table(table_name)
7272
yield table
7373

7474
def _item_to_access_token(self, item: dict[str, Any] | None) -> AP | None:
@@ -100,7 +100,7 @@ async def get_by_token(
100100
self, token: str, max_age: datetime | None = None
101101
) -> AP | None:
102102
"""Retrieve an access token by token string."""
103-
async with self._table() as table:
103+
async with self._table(self.table_name) as table:
104104
resp = await table.get_item(Key={"token": self._ensure_token(token)})
105105
item = resp.get("Item")
106106

@@ -125,7 +125,7 @@ async def create(self, create_dict: dict[str, Any]) -> AP:
125125
if isinstance(item.get("user_id"), uuid.UUID):
126126
item["user_id"] = str(item["user_id"])
127127

128-
async with self._table() as table:
128+
async with self._table(self.table_name) as table:
129129
await table.put_item(Item=item)
130130

131131
resp = await table.get_item(Key={"token": item["token"]})
@@ -153,7 +153,7 @@ async def update(self, access_token: AP, update_dict: dict[str, Any]) -> AP:
153153
if isinstance(token_dict.get("created_at"), datetime):
154154
token_dict["created_at"] = token_dict["created_at"].isoformat()
155155

156-
async with self._table() as table:
156+
async with self._table(self.table_name) as table:
157157
await table.put_item(Item=token_dict)
158158

159159
resp = await table.get_item(Key={"token": token_dict["token"]})
@@ -172,5 +172,5 @@ async def delete(self, access_token: AP) -> None:
172172
if token is None:
173173
raise ValueError("access_token has no 'token' field")
174174

175-
async with self._table() as table:
175+
async with self._table(self.table_name) as table:
176176
await table.delete_item(Key={"token": self._ensure_token(token)})

pyproject.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.mypy]
2-
plugins = "sqlalchemy.ext.mypy.plugin"
2+
plugins = []
33

44
[tool.pytest.ini_options]
55
asyncio_mode = "strict"
@@ -24,9 +24,7 @@ path = "fastapi_users_db_dynamodb/__init__.py"
2424
[tool.hatch.envs.default]
2525
installer = "uv"
2626
dependencies = [
27-
"aiosqlite",
28-
"asyncpg",
29-
"aiomysql",
27+
"aioboto3",
3028
"pytest",
3129
"pytest-asyncio",
3230
"black",
@@ -37,7 +35,6 @@ dependencies = [
3735
"httpx",
3836
"asgi_lifespan",
3937
"ruff",
40-
"sqlalchemy[asyncio,mypy]",
4138
]
4239

4340
[tool.hatch.envs.default.scripts]
@@ -86,9 +83,9 @@ classifiers = [
8683
requires-python = ">=3.9"
8784
dependencies = [
8885
"fastapi-users >= 10.0.0",
89-
"sqlalchemy[asyncio] >=2.0.0,<2.1.0",
86+
"aioboto3 >= 11.0.0",
9087
]
9188

9289
[project.urls]
9390
Documentation = "https://fastapi-users.github.io/fastapi-users"
94-
Source = "https://github.com/fastapi-users/fastapi-users-db-dynamodb"
91+
Source = "https://github.com/AppSolves/fastapi-users-db-dynamodb"

0 commit comments

Comments
 (0)