Skip to content

Commit 2571144

Browse files
committed
fix: remove small bugs
1 parent 192bccf commit 2571144

File tree

13 files changed

+32
-24
lines changed

13 files changed

+32
-24
lines changed

deployments/dev/backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ WORKDIR /app
44

55
ENV UV_LINK_MODE copy
66
ENV UV_PROJECT_ENVIRONMENT /run/app/.venv
7-
ENV UV_CACHE_DIR copy /run/app/uv
7+
ENV UV_CACHE_DIR /run/app/uv
88

99
ENV PYTHONPATH /app/src:/app/tests
1010
ENV WATCHFILES_FORCE_POLLING true

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ build-backend = "hatchling.build"
4242
packages = ["src/app_name_snake_case"]
4343

4444
[project.scripts]
45-
app-name-kebab-case-fastapi-dev = "app_name_snake_case.entrypoint.web_service.__main__:main"
45+
app-name-kebab-case-fastapi-dev = "app_name_snake_case.main.fastapi.__main__:main"
4646

4747
[tool.mypy]
4848
mypy_path = "$MYPY_CONFIG_FILE_DIR/src:$MYPY_CONFIG_FILE_DIR/tests"

src/app_name_snake_case/application/view_user.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from dataclasses import dataclass
22

3+
from app_name_snake_case.application.ports.transaction import Transaction
34
from app_name_snake_case.application.ports.user_id_signing import UserIDSigning
45
from app_name_snake_case.application.ports.user_views import UserViews
56

@@ -8,6 +9,7 @@
89
class ViewUser[SignedUserIDT, UserViewT, UserViewWithIDT]:
910
user_id_signing: UserIDSigning[SignedUserIDT]
1011
user_views: UserViews[UserViewT, UserViewWithIDT]
12+
transaction: Transaction
1113

1214
async def __call__(
1315
self, signed_user_id: SignedUserIDT | None
@@ -19,4 +21,5 @@ async def __call__(
1921
signed_user_id=signed_user_id
2022
)
2123

22-
return await self.user_views.view_of_user_with_id(user_id)
24+
async with self.transaction:
25+
return await self.user_views.view_of_user_with_id(user_id)

src/app_name_snake_case/main/common/di.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async def provide_postgres_session(
5858
@provide(scope=Scope.APP)
5959
def provide_user_id_signing(
6060
self, envs: Envs
61-
) -> UserIDSigning[str]:
61+
) -> AnyOf[UserIDSigningToHS256JWT, UserIDSigning[JWT]]:
6262
return UserIDSigningToHS256JWT(secret=envs.jwt_secret)
6363

6464
@provide(scope=Scope.REQUEST)

src/app_name_snake_case/presentation/adapters/user_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async def view_of_user_with_id(
2727
return None
2828

2929
user_name: str | None = await self.session.scalar(
30-
select(user_table.c.name).where(user_table.c.name)
30+
select(user_table.c.name).where(user_table.c.id == user_id)
3131
)
3232
if user_name is None:
3333
return None

src/app_name_snake_case/presentation/fastapi/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async def app_from(container: AsyncContainer) -> FastAPI:
5454
app = _FastAPIWithAdditionalModels(
5555
title="app-name-kebab-case",
5656
version=version,
57-
summary="app_name_description",
57+
summary="app_name_description.",
5858
openapi_tags=tags_metadata,
5959
contact={"name": "Alexander Smolin", "url": author_url},
6060
license_info={

src/app_name_snake_case/presentation/fastapi/cookies.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ def __new__(
4545
] # type: ignore[assignment]
4646
type_.StrWithLock = Annotated[str, Depends(api_key_with_auto_error)] # type: ignore[assignment]
4747

48-
type_.StrOrNone = Annotated[
49-
str | None, FastAPICookie(alias=key, default=None)
50-
] # type: ignore[assignment]
48+
type_.StrOrNone = Annotated[str | None, FastAPICookie(alias=key)] # type: ignore[assignment]
5149
type_.Str = Annotated[str, FastAPICookie(alias=key)] # type: ignore[assignment]
5250

5351
type_.key = key

src/app_name_snake_case/presentation/fastapi/routes/view_user.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class RegisterUserSchema(BaseModel):
2121
"/user",
2222
responses={
2323
status.HTTP_200_OK: {"model": UserSchema},
24-
status.HTTP_204_NO_CONTENT: {"model": NoDataSchema},
24+
status.HTTP_204_NO_CONTENT: {},
2525
},
2626
summary="View user",
2727
description="View current user.",
@@ -34,6 +34,8 @@ async def view_user_route(
3434
) -> Response:
3535
view = await view_user(signed_user_id=signed_user_id)
3636

37-
response_model = NoDataSchema() if view is None else view
38-
response_body = response_model.model_dump(mode="json", by_alias=True)
37+
if view is None:
38+
return Response(b"", status_code=status.HTTP_204_NO_CONTENT)
39+
40+
response_body = view.model_dump(mode="json", by_alias=True)
3941
return JSONResponse(response_body)

tests/test_app_name_snake_case/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from app_name_snake_case.infrastructure.typenv.envs import Envs
21
from pytest import Item, fixture, mark
32
from pytest_asyncio import is_async_test
43

4+
from app_name_snake_case.infrastructure.typenv.envs import Envs
5+
56

67
@fixture(scope="session")
78
def envs() -> Envs:

tests/test_app_name_snake_case/test_infrastructure/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from collections.abc import AsyncIterable
22

3-
from app_name_snake_case.infrastructure.sqlalchemy.tables import metadata
4-
from app_name_snake_case.infrastructure.typenv.envs import Envs
53
from pytest import fixture
64
from sqlalchemy import NullPool, delete
75
from sqlalchemy.ext.asyncio import (
@@ -10,6 +8,9 @@
108
create_async_engine,
119
)
1210

11+
from app_name_snake_case.infrastructure.sqlalchemy.tables import metadata
12+
from app_name_snake_case.infrastructure.typenv.envs import Envs
13+
1314

1415
@fixture(scope="session")
1516
def engine(envs: Envs) -> AsyncEngine:

0 commit comments

Comments
 (0)