From 36222025da2fdac5408d316f8d36b17ad462eb6e Mon Sep 17 00:00:00 2001 From: jonra1993 Date: Sat, 24 Feb 2024 12:44:17 -0500 Subject: [PATCH] Format code --- backend/app/app/api/v1/endpoints/login.py | 2 +- backend/app/app/crud/base_crud.py | 2 +- backend/app/app/db/session.py | 4 ++-- backend/app/app/main.py | 3 +-- backend/app/app/models/base_uuid_model.py | 1 + backend/app/app/models/team_model.py | 1 - backend/app/app/models/user_follow_model.py | 4 +++- backend/app/app/schemas/hero_schema.py | 2 +- backend/app/app/schemas/image_media_schema.py | 6 +++--- backend/app/app/schemas/team_schema.py | 1 - backend/app/app/schemas/user_schema.py | 2 +- backend/app/app/utils/partial.py | 1 - 12 files changed, 14 insertions(+), 15 deletions(-) diff --git a/backend/app/app/api/v1/endpoints/login.py b/backend/app/app/api/v1/endpoints/login.py index 07a3968..126bee5 100644 --- a/backend/app/app/api/v1/endpoints/login.py +++ b/backend/app/app/api/v1/endpoints/login.py @@ -158,7 +158,7 @@ async def get_new_access_token( status_code=status.HTTP_403_FORBIDDEN, detail="Error when decoding the token. Please check your request.", ) - except MissingRequiredClaimError as e: + except MissingRequiredClaimError: raise HTTPException( status_code=status.HTTP_403_FORBIDDEN, detail="There is no required field in your token. Please contact the administrator.", diff --git a/backend/app/app/crud/base_crud.py b/backend/app/app/crud/base_crud.py index 993771a..8f13c80 100644 --- a/backend/app/app/crud/base_crud.py +++ b/backend/app/app/crud/base_crud.py @@ -85,7 +85,7 @@ async def get_multi_paginated( db_session = db_session or self.db.session if query is None: query = select(self.model) - + output = await paginate(db_session, query, params) return output diff --git a/backend/app/app/db/session.py b/backend/app/app/db/session.py index 2f70633..14cdc28 100644 --- a/backend/app/app/db/session.py +++ b/backend/app/app/db/session.py @@ -34,8 +34,8 @@ str(settings.ASYNC_CELERY_BEAT_DATABASE_URI), # echo=True, future=True, - #pool_size=POOL_SIZE, - #max_overflow=64, + # pool_size=POOL_SIZE, + # max_overflow=64, ) SessionLocalCelery = sessionmaker( diff --git a/backend/app/app/main.py b/backend/app/app/main.py index 14120a3..c178806 100644 --- a/backend/app/app/main.py +++ b/backend/app/app/main.py @@ -17,7 +17,6 @@ from fastapi_cache.backends.redis import RedisBackend from fastapi_limiter import FastAPILimiter from fastapi_limiter.depends import WebSocketRateLimiter -from fastapi_pagination import add_pagination from jwt import DecodeError, ExpiredSignatureError, MissingRequiredClaimError from langchain.chat_models import ChatOpenAI from langchain.schema import HumanMessage @@ -237,4 +236,4 @@ async def websocket_endpoint(websocket: WebSocket, user_id: UUID): # Add Routers -app.include_router(api_router_v1, prefix=settings.API_V1_STR) \ No newline at end of file +app.include_router(api_router_v1, prefix=settings.API_V1_STR) diff --git a/backend/app/app/models/base_uuid_model.py b/backend/app/app/models/base_uuid_model.py index 3fc4838..d7e89cf 100644 --- a/backend/app/app/models/base_uuid_model.py +++ b/backend/app/app/models/base_uuid_model.py @@ -4,6 +4,7 @@ from sqlalchemy.orm import declared_attr from datetime import datetime + # id: implements proposal uuid7 draft4 class SQLModel(_SQLModel): @declared_attr # type: ignore diff --git a/backend/app/app/models/team_model.py b/backend/app/app/models/team_model.py index a6fd909..cb0f727 100644 --- a/backend/app/app/models/team_model.py +++ b/backend/app/app/models/team_model.py @@ -4,7 +4,6 @@ from uuid import UUID - class TeamBase(SQLModel): name: str = Field(index=True) headquarters: str diff --git a/backend/app/app/models/user_follow_model.py b/backend/app/app/models/user_follow_model.py index e1f5225..2f9f3f4 100644 --- a/backend/app/app/models/user_follow_model.py +++ b/backend/app/app/models/user_follow_model.py @@ -10,4 +10,6 @@ class UserFollowBase(SQLModel): class UserFollow(BaseUUIDModel, UserFollowBase, table=True): - is_mutual: bool | None = Field(default=None, sa_column=Column(Boolean(), server_default="0")) + is_mutual: bool | None = Field( + default=None, sa_column=Column(Boolean(), server_default="0") + ) diff --git a/backend/app/app/schemas/hero_schema.py b/backend/app/app/schemas/hero_schema.py index 7ddfe97..0878e6f 100644 --- a/backend/app/app/schemas/hero_schema.py +++ b/backend/app/app/schemas/hero_schema.py @@ -6,7 +6,7 @@ class IHeroCreate(HeroBase): - @field_validator('age') + @field_validator("age") def check_age(cls, value): if value < 0: raise ValueError("Invalid age") diff --git a/backend/app/app/schemas/image_media_schema.py b/backend/app/app/schemas/image_media_schema.py index d20c96e..61382d0 100644 --- a/backend/app/app/schemas/image_media_schema.py +++ b/backend/app/app/schemas/image_media_schema.py @@ -1,6 +1,6 @@ from app.models.image_media_model import ImageMedia, ImageMediaBase from app.models.media_model import Media -from pydantic import model_validator, root_validator +from pydantic import model_validator from .media_schema import IMediaRead from app.utils.partial import optional @@ -20,11 +20,11 @@ class IImageMediaRead(ImageMediaBase): media: IMediaRead | None -#Todo make it compatible with pydantic v2 +# Todo make it compatible with pydantic v2 class IImageMediaReadCombined(ImageMediaBase): link: str | None - @model_validator(mode='before') + @model_validator(mode="before") def combine_attributes(cls, values): link_fields = {"link": values.get("link", None)} if "media" in values: diff --git a/backend/app/app/schemas/team_schema.py b/backend/app/app/schemas/team_schema.py index eb78ba5..968abfd 100644 --- a/backend/app/app/schemas/team_schema.py +++ b/backend/app/app/schemas/team_schema.py @@ -1,4 +1,3 @@ -from typing import Any from app.models.hero_model import HeroBase from app.models.team_model import TeamBase from .user_schema import IUserBasicInfo diff --git a/backend/app/app/schemas/user_schema.py b/backend/app/app/schemas/user_schema.py index 7c1710d..47038b0 100644 --- a/backend/app/app/schemas/user_schema.py +++ b/backend/app/app/schemas/user_schema.py @@ -4,7 +4,7 @@ from pydantic import BaseModel from uuid import UUID from enum import Enum -from .image_media_schema import IImageMediaReadCombined, IImageMediaRead +from .image_media_schema import IImageMediaRead from .role_schema import IRoleRead diff --git a/backend/app/app/utils/partial.py b/backend/app/app/utils/partial.py index f0054d4..b703a0d 100644 --- a/backend/app/app/utils/partial.py +++ b/backend/app/app/utils/partial.py @@ -2,7 +2,6 @@ # https://github.com/pydantic/pydantic/pull/3179 # https://github.com/pydantic/pydantic/issues/1673 -from pydantic import BaseModel from copy import deepcopy from typing import Any, Callable, Optional, Type, TypeVar from pydantic import BaseModel, create_model