Skip to content

Commit c1e2353

Browse files
committed
refactor: Replace pydantic.v1 imports with standard pydantic and fix import inconsistencies
1 parent 1acfd7b commit c1e2353

6 files changed

Lines changed: 12 additions & 9 deletions

File tree

app/controller/api/v1/dummy/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from fastapi import APIRouter, Body, Depends, Path, Query, Request, status
44
from fastapi.responses import JSONResponse, Response
55
from loguru import logger
6-
from pydantic.v1 import UUID4
6+
from pydantic import UUID4
77
from sqlalchemy.ext.asyncio import AsyncSession
88

99
from app.controller.api.v1.dummy.schema import (

app/controller/api/v1/rabbit/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ async def send_rabbit_message(
2424
async with pool.acquire() as conn:
2525
exchange = await conn.declare_exchange(
2626
name=message.exchange_name,
27-
auto_delete=True,
27+
durable=True,
28+
auto_delete=False,
2829
)
2930
await exchange.publish(
3031
message=Message(

app/core/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ def redis_url(self) -> URL:
217217
scheme="redis",
218218
host=self.REDIS_HOST,
219219
port=self.REDIS_PORT,
220-
user=self.REDIS_USER,
221220
password=self.REDIS_PASS,
222221
path=path,
223222
)

app/core/tkq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919

2020
taskiq_fastapi.init(
2121
broker,
22-
"app.controller.application:get_app",
22+
"app.core.application:get_app",
2323
)

app/db/dao/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"""Data Access Object with default methods to Create, Read, Update, Delete (CRUD)."""
22

3+
import uuid
34
from collections.abc import Sequence
45
from typing import TYPE_CHECKING, Any, Generic, Literal, TypeVar
56

67
from loguru import logger
78
from pydantic import UUID4, BaseModel, Field
8-
from sqlalchemy import UUID, func, or_, select
9+
from sqlalchemy import func, or_, select
910
from sqlalchemy.exc import OperationalError
1011
from sqlalchemy.ext.asyncio import AsyncSession
1112
from sqlalchemy.orm import InstrumentedAttribute
@@ -33,7 +34,7 @@ class Filter(BaseModel):
3334
...,
3435
examples=["eq"],
3536
)
36-
value: str | int | float | bool | UUID = Field(..., examples=["John Doe"])
37+
value: str | int | float | bool | uuid.UUID = Field(..., examples=["John Doe"])
3738

3839

3940
class DAOBase(Generic[ModelType]):

app/db/models/base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
Dataclass style for powerful autocompletion support.
55
"""
66

7+
import uuid
78
from datetime import UTC, datetime
8-
from uuid import uuid4
99

1010
from sqlalchemy import UUID, DateTime, func
1111
from sqlalchemy.orm import DeclarativeBase, Mapped, declared_attr, mapped_column
@@ -35,11 +35,13 @@ class Base(BaseMetadata):
3535
__tablename__(): Returns the table name, which is the lowercased class name.
3636
"""
3737

38-
id: Mapped[UUID] = mapped_column(
38+
__abstract__ = True
39+
40+
id: Mapped[uuid.UUID] = mapped_column(
3941
UUID(as_uuid=True),
4042
primary_key=True,
4143
index=True,
42-
default=uuid4,
44+
default=uuid.uuid4,
4345
)
4446

4547
# Generate __tablename__ automatically

0 commit comments

Comments
 (0)