From c37d89fa67680c7b874c479cffd54025c5644f6b Mon Sep 17 00:00:00 2001 From: grillazz Date: Sun, 15 May 2022 13:58:16 +0200 Subject: [PATCH] python 3.10 improvements --- the_app/api/stuff.py | 4 +--- the_app/config.py | 2 +- the_app/models/__init__.py | 2 +- the_app/utils.py | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/the_app/api/stuff.py b/the_app/api/stuff.py index e1f57a7..93b8acf 100644 --- a/the_app/api/stuff.py +++ b/the_app/api/stuff.py @@ -1,5 +1,3 @@ -from typing import List - from fastapi import APIRouter, Depends, HTTPException, status from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.ext.asyncio import AsyncSession @@ -15,7 +13,7 @@ logger = get_logger(__name__) @router.post("/add_many", status_code=status.HTTP_201_CREATED) -async def create_multi_stuff(payload: List[StuffSchema], db_session: AsyncSession = Depends(get_db)): +async def create_multi_stuff(payload: list[StuffSchema], db_session: AsyncSession = Depends(get_db)): try: stuff_instances = [Stuff(name=stuf.name, description=stuf.description) for stuf in payload] db_session.add_all(stuff_instances) diff --git a/the_app/config.py b/the_app/config.py index efab465..116b3b4 100644 --- a/the_app/config.py +++ b/the_app/config.py @@ -38,7 +38,7 @@ class Settings(BaseSettings): jwt_access_toke_expire_minutes: int = os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", 1) -@lru_cache() +@lru_cache def get_settings(): logger.info("Loading config settings from the environment...") return Settings() diff --git a/the_app/models/__init__.py b/the_app/models/__init__.py index 63287f6..abb31f4 100644 --- a/the_app/models/__init__.py +++ b/the_app/models/__init__.py @@ -1,3 +1,3 @@ from the_app.models.nonsense import Nonsense # noqa -from the_app.models.stuff import Stuff # noqa from the_app.models.shakespeare import Character # noqa +from the_app.models.stuff import Stuff # noqa diff --git a/the_app/utils.py b/the_app/utils.py index d2f9f52..6c1ba75 100644 --- a/the_app/utils.py +++ b/the_app/utils.py @@ -7,7 +7,7 @@ from rich.logging import RichHandler console = Console(color_system="256", width=200, style="blue") -@lru_cache() +@lru_cache def get_logger(module_name): logger = logging.getLogger(module_name) handler = RichHandler(rich_tracebacks=True, console=console, tracebacks_show_locals=True)