Skip to content

Commit 8cdaf4e

Browse files
committed
Docstrings
1 parent 3f888cb commit 8cdaf4e

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

fastapi_users_db_dynamodb/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""FastAPI Users database adapter for AWS DynamoDB.
22
33
This adapter mirrors the SQLAlchemy adapter's public API and return types as closely
4-
as reasonably possible while using DynamoDB via aiopynamodb.
4+
as reasonably possible while using DynamoDB via `aiopynamodb`.
55
66
Usage notes:
77
- This adapter is expected to function correctly, but it is still advisable to exercise
88
caution in production environments (yet).
9-
- This will create non existent tables by default. You can tweak the creation inside generics.py
10-
- This will require ON-DEMAND mode, since traffic is unpredictable in all auth tables!
9+
- The Database will create non existent tables by default. You can customize the configuration
10+
inside `config.py` using the `get` and `set` methods.
11+
- For now, tables will require ON-DEMAND mode, since traffic is unpredictable in all auth tables!
1112
"""
1213

1314
import uuid
@@ -23,10 +24,9 @@
2324
from . import config
2425
from ._generics import UUID_ID
2526
from .attributes import GUID, TransformingUnicodeAttribute
27+
from .config import __version__ # noqa: F401
2628
from .tables import ensure_tables_exist
2729

28-
__version__: str = "1.0.0"
29-
3030

3131
class DynamoDBBaseUserTable(Model, Generic[ID]):
3232
"""Base user table schema for DynamoDB."""
@@ -252,10 +252,10 @@ async def add_oauth_account(self, user: UP, create_dict: dict[str, Any]) -> UP:
252252
except PutError as e:
253253
if e.cause_response_code == "ConditionalCheckFailedException":
254254
raise ValueError(
255-
"OAuth account could not be updated because it already exists."
255+
"OAuth account could not be added because it already exists."
256256
) from e
257257
raise ValueError(
258-
"OAuth account could not be updated because the table does not exist."
258+
"OAuth account could not be added because the table does not exist."
259259
) from e
260260

261261
return user

fastapi_users_db_dynamodb/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from enum import StrEnum
22
from typing import Any, Literal, TypedDict
33

4+
__version__: str = "1.0.0"
5+
46

57
# Right now, only ON-DEMAND mode is supported!
68
class BillingMode(StrEnum):

fastapi_users_db_dynamodb/tables.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212

1313
class CreatableTable(Protocol):
14+
"""
15+
A protocol class representing PynamoDB tables (`Model`) which can be created.
16+
"""
17+
1418
@classmethod
1519
async def exists(cls) -> CoroutineType[Any, Any, bool] | bool: ...
1620

@@ -23,7 +27,8 @@ async def create_table(
2327
) -> CoroutineType[Any, Any, Any] | Any: ...
2428

2529

26-
def _check_creatable_table(cls: type[Any]):
30+
def __check_creatable_table(cls: type[Any]):
31+
"""Check if an object is of type `CreatableTable`"""
2732
if not issubclass(cls, Model):
2833
raise TypeError(f"{cls.__name__} must be a subclass of Model")
2934
if not hasattr(cls, "exists") or not hasattr(cls, "create_table"):
@@ -38,7 +43,7 @@ async def ensure_tables_exist(*tables: type[CreatableTable]) -> None:
3843
global __tables_cache
3944

4045
for table_cls in tables:
41-
_check_creatable_table(table_cls)
46+
__check_creatable_table(table_cls)
4247
if table_cls not in __tables_cache:
4348
if not await table_cls.exists():
4449
await table_cls.create_table(

0 commit comments

Comments
 (0)