diff --git a/app/routes/base.py b/app/routes/base.py index f2f8108..b33b2c2 100644 --- a/app/routes/base.py +++ b/app/routes/base.py @@ -12,9 +12,9 @@ app.add_middleware( CORSMiddleware, allow_origins=settings.CORS_ALLOW_ORIGINS, - allow_credentials=settings.CORS_ALLOW_CREDENTIALS, - allow_methods=settings.CORS_ALLOW_METHODS, - allow_headers=settings.CORS_ALLOW_HEADERS, + allow_credentials=str(settings.CORS_ALLOW_CREDENTIALS), + allow_methods=str(settings.CORS_ALLOW_METHODS), + allow_headers=str(settings.CORS_ALLOW_HEADERS), ) app.include_router(script_router, prefix='', tags=['User']) diff --git a/app/routes/models/base.py b/app/routes/models/base.py index d96d4d5..7748216 100644 --- a/app/routes/models/base.py +++ b/app/routes/models/base.py @@ -1,12 +1,11 @@ -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict class Base(BaseModel): def __repr__(self) -> str: attrs = [] - for k, v in self.__class__.schema().items(): + for k, v in self.__class__.model_json_schema().items(): attrs.append(f"{k}={v}") return "{}({})".format(self.__class__.__name__, ', '.join(attrs)) - class Config: - orm_mode = True + model_config = ConfigDict(from_attributes=True, extra="ignore") diff --git a/app/routes/script_launch.py b/app/routes/script_launch.py index 6051085..981150a 100644 --- a/app/routes/script_launch.py +++ b/app/routes/script_launch.py @@ -24,7 +24,7 @@ class SendOutput(BaseModel): async def run_script( action: str, inp: Input, - user: dict = Depends(UnionAuth(scopes=[] if settings.ALLOWED_SCOPE is None else [settings.ALLOWED_SCOPE])) + user: dict = Depends(UnionAuth(scopes=[] if settings.ALLOWED_SCOPE is None else [settings.ALLOWED_SCOPE])), ): """runs a bash script, located in scripts/{action}. The script takes 2 arguments: git_ref and repo_url""" diff --git a/app/settings.py b/app/settings.py index 99025dd..24177ea 100644 --- a/app/settings.py +++ b/app/settings.py @@ -1,6 +1,7 @@ from functools import lru_cache -from pydantic import AnyUrl, BaseSettings, PostgresDsn +from pydantic import AnyUrl, ConfigDict, PostgresDsn +from pydantic_settings import BaseSettings class Settings(BaseSettings): @@ -13,11 +14,7 @@ class Settings(BaseSettings): CORS_ALLOW_METHODS: list[str] = ['*'] CORS_ALLOW_HEADERS: list[str] = ['*'] - class Config: - """Pydantic BaseSettings config""" - - case_sensitive = True - env_file = ".env" + model_config = ConfigDict(case_sensitive=True, env_file=".env", extra="ignore") @lru_cache diff --git a/requirements.txt b/requirements.txt index 9f67345..cb1d6b1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ fastapi -pydantic[dotenv] +pydantic +pydantic_settings uvicorn gunicorn auth_lib_profcomff[fastapi]