[isort] ran with black profile
All checks were successful
Python lint and test / linttest (push) Successful in 5m30s

This commit is contained in:
Piotr Domański 2024-08-04 16:17:16 +02:00
parent a13d926794
commit e2af49046c
34 changed files with 116 additions and 98 deletions

View file

@ -1,8 +1,8 @@
from fastapi import FastAPI
from .router import router
from .settings import Settings
from fastapi.middleware.cors import CORSMiddleware
from .router import router
from .settings import Settings
app = FastAPI(title="Fooder")
app.include_router(router)

View file

@ -1,16 +1,17 @@
from datetime import datetime, timedelta
from typing import Annotated
from fastapi import Depends, HTTPException
from fastapi.security import OAuth2PasswordBearer
from fastapi_users.password import PasswordHelper
from jose import JWTError, jwt
from passlib.context import CryptContext
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
from jose import JWTError, jwt
from fastapi.security import OAuth2PasswordBearer
from fastapi import Depends, HTTPException
from fastapi_users.password import PasswordHelper
from typing import Annotated
from datetime import datetime, timedelta
from .settings import Settings
from .domain.user import User
from .domain.token import RefreshToken
from .db import get_session
from .db import get_session
from .domain.token import RefreshToken
from .domain.user import User
from .settings import Settings
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="api/token")

View file

@ -1,10 +1,11 @@
from typing import Annotated, Any
from fastapi import Depends
from sqlalchemy.ext.asyncio import async_sessionmaker
from ..db import get_session
from ..auth import get_current_user, authorize_api_key
from ..domain.user import User
from ..auth import authorize_api_key, get_current_user
from ..db import get_session
from ..domain.user import User
AsyncSession = Annotated[async_sessionmaker, Depends(get_session)]
UserDependency = Annotated[User, Depends(get_current_user)]

View file

@ -1,8 +1,9 @@
from datetime import date
from fastapi import HTTPException
from ..model.diary import Diary
from ..domain.diary import Diary as DBDiary
from ..model.diary import Diary
from .base import AuthorizedController

View file

@ -1,8 +1,8 @@
from fastapi import HTTPException
from ..model.entry import Entry, CreateEntryPayload, UpdateEntryPayload
from ..domain.entry import Entry as DBEntry
from ..domain.meal import Meal as DBMeal
from ..model.entry import CreateEntryPayload, Entry, UpdateEntryPayload
from .base import AuthorizedController

View file

@ -1,15 +1,15 @@
from fastapi import HTTPException
from ..domain.diary import Diary as DBDiary
from ..domain.meal import Meal as DBMeal
from ..domain.preset import Preset as DBPreset
from ..model.meal import (
Meal,
CreateMealPayload,
SaveMealPayload,
CreateMealFromPresetPayload,
CreateMealPayload,
Meal,
SaveMealPayload,
)
from ..model.preset import Preset
from ..domain.meal import Meal as DBMeal
from ..domain.diary import Diary as DBDiary
from ..domain.preset import Preset as DBPreset
from .base import AuthorizedController

View file

@ -1,8 +1,9 @@
from typing import AsyncIterator, Optional
from fastapi import HTTPException
from ..model.preset import Preset, PresetDetails
from ..domain.preset import Preset as DBPreset
from ..model.preset import Preset, PresetDetails
from .base import AuthorizedController

View file

@ -2,9 +2,9 @@ from typing import AsyncIterator, Optional
from fastapi import HTTPException
from ..utils import product_finder
from ..model.product import Product, CreateProductPayload
from ..domain.product import Product as DBProduct
from ..model.product import CreateProductPayload, Product
from ..utils import product_finder
from .base import AuthorizedController

View file

@ -1,4 +1,5 @@
from fastapi import HTTPException
from ..domain.product import Product as DBProduct
from .base import TasksSessionController

View file

@ -1,15 +1,15 @@
from fastapi import HTTPException
from fastapi.security import OAuth2PasswordRequestForm
from ..model.token import Token, RefreshTokenPayload
from ..domain.user import User as DBUser
from .base import BaseController
from ..auth import (
authenticate_user,
create_access_token,
create_refresh_token,
verify_refresh_token,
)
from ..domain.user import User as DBUser
from ..model.token import RefreshTokenPayload, Token
from .base import BaseController
class CreateToken(BaseController):

View file

@ -1,7 +1,7 @@
from fastapi import HTTPException
from ..model.user import User, CreateUserPayload
from ..domain.user import User as DBUser
from ..model.user import CreateUserPayload, User
from .base import BaseController

View file

@ -1,4 +1,4 @@
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, declared_attr
from sqlalchemy.orm import DeclarativeBase, Mapped, declared_attr, mapped_column
class Base(DeclarativeBase):

View file

@ -1,14 +1,14 @@
from sqlalchemy.orm import relationship, Mapped, mapped_column, joinedload
from sqlalchemy import ForeignKey, Integer, Date
from sqlalchemy import select
from sqlalchemy.sql.selectable import Select
from sqlalchemy.ext.asyncio import AsyncSession
import datetime
from typing import Optional
from sqlalchemy import Date, ForeignKey, Integer, select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Mapped, joinedload, mapped_column, relationship
from sqlalchemy.sql.selectable import Select
from .base import Base, CommonMixin
from .meal import Meal
from .entry import Entry
from .meal import Meal
class Diary(Base, CommonMixin):

View file

@ -1,11 +1,11 @@
from sqlalchemy.orm import Mapped, mapped_column, relationship, joinedload
from sqlalchemy import ForeignKey, Integer, DateTime, Boolean
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.exc import IntegrityError
from sqlalchemy import select, update
from datetime import datetime
from typing import Optional
from sqlalchemy import Boolean, DateTime, ForeignKey, Integer, select, update
from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Mapped, joinedload, mapped_column, relationship
from .base import Base, CommonMixin
from .product import Product

View file

@ -1,10 +1,10 @@
from sqlalchemy.orm import relationship, Mapped, mapped_column, joinedload
from sqlalchemy import ForeignKey, Integer
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.exc import IntegrityError
from typing import Optional
from sqlalchemy import ForeignKey, Integer, select
from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Mapped, joinedload, mapped_column, relationship
from .base import Base, CommonMixin
from .entry import Entry
from .preset import Preset

View file

@ -1,11 +1,11 @@
from sqlalchemy.orm import relationship, Mapped, mapped_column, joinedload
from sqlalchemy.ext.asyncio import AsyncSession
from typing import TYPE_CHECKING, AsyncIterator, Optional
from sqlalchemy import ForeignKey, Integer, select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Mapped, joinedload, mapped_column, relationship
from .base import Base, CommonMixin
from .preset_entry import PresetEntry
from typing import AsyncIterator, Optional, TYPE_CHECKING
if TYPE_CHECKING:
from .meal import Meal

View file

@ -1,12 +1,13 @@
from sqlalchemy.orm import Mapped, mapped_column, relationship
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.exc import IntegrityError
from sqlalchemy import ForeignKey, Integer, DateTime
from datetime import datetime
from sqlalchemy import DateTime, ForeignKey, Integer
from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Mapped, mapped_column, relationship
from .base import Base, CommonMixin
from .product import Product
from .entry import Entry
from .product import Product
class PresetEntry(Base, CommonMixin):

View file

@ -1,8 +1,9 @@
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy import select, BigInteger, func, update
from sqlalchemy.ext.asyncio import AsyncSession
from typing import AsyncIterator, Optional
from sqlalchemy import BigInteger, func, select, update
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Mapped, mapped_column
from .base import Base, CommonMixin

View file

@ -1,9 +1,9 @@
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy import ForeignKey, Integer
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from typing import Optional
from sqlalchemy import ForeignKey, Integer, select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Mapped, mapped_column
from .base import Base, CommonMixin

View file

@ -1,7 +1,8 @@
from sqlalchemy.orm import Mapped
from typing import Optional
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from typing import Optional
from sqlalchemy.orm import Mapped
from .base import Base, CommonMixin

View file

@ -1,6 +1,7 @@
from pydantic import BaseModel
from typing import List
from datetime import date
from typing import List
from pydantic import BaseModel
from .meal import Meal

View file

@ -1,6 +1,7 @@
from pydantic import BaseModel
from typing import Optional
from pydantic import BaseModel
from .product import Product

View file

@ -1,5 +1,7 @@
from pydantic import BaseModel
from typing import List, Optional
from pydantic import BaseModel
from .entry import Entry

View file

@ -1,5 +1,7 @@
from pydantic import BaseModel
from typing import List
from pydantic import BaseModel
from .preset_entry import PresetEntry

View file

@ -1,6 +1,7 @@
from pydantic_settings import BaseSettings
from typing import List
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
"""Settings."""

View file

@ -1,8 +1,8 @@
from fastapi import FastAPI
from .view.tasks import router
from .settings import Settings
from fastapi.middleware.cors import CORSMiddleware
from .settings import Settings
from .view.tasks import router
app = FastAPI(title="Fooder Tasks admininstrative API")
app.include_router(router)

View file

@ -1,7 +1,7 @@
import requests as r
from dataclasses import dataclass
from logging import getLogger
import requests as r
logger = getLogger(__name__)

View file

@ -1,8 +1,9 @@
from fastapi import APIRouter, Depends, Request
from ..model.diary import Diary
from ..controller.diary import GetDiary
from datetime import date
from fastapi import APIRouter, Depends, Request
from ..controller.diary import GetDiary
from ..model.diary import Diary
router = APIRouter(tags=["diary"])

View file

@ -1,7 +1,7 @@
from fastapi import APIRouter, Depends, Request
from ..model.entry import Entry, CreateEntryPayload, UpdateEntryPayload
from ..controller.entry import CreateEntry, UpdateEntry, DeleteEntry
from ..controller.entry import CreateEntry, DeleteEntry, UpdateEntry
from ..model.entry import CreateEntryPayload, Entry, UpdateEntryPayload
router = APIRouter(tags=["entry"])

View file

@ -1,13 +1,13 @@
from fastapi import APIRouter, Depends, Request
from ..model.preset import Preset
from ..model.meal import (
Meal,
CreateMealPayload,
SaveMealPayload,
CreateMealFromPresetPayload,
)
from ..controller.meal import CreateMeal, SaveMeal, CreateMealFromPreset, DeleteMeal
from ..controller.meal import CreateMeal, CreateMealFromPreset, DeleteMeal, SaveMeal
from ..model.meal import (
CreateMealFromPresetPayload,
CreateMealPayload,
Meal,
SaveMealPayload,
)
from ..model.preset import Preset
router = APIRouter(tags=["meal"])

View file

@ -1,7 +1,7 @@
from fastapi import APIRouter, Depends, Request
from ..model.preset import ListPresetsPayload, PresetDetails
from ..controller.preset import ListPresets, DeletePreset, GetPreset
from ..controller.preset import DeletePreset, GetPreset, ListPresets
from ..model.preset import ListPresetsPayload, PresetDetails
router = APIRouter(tags=["preset"])

View file

@ -1,8 +1,9 @@
from fastapi import APIRouter, Depends, Request
from ..model.product import Product, CreateProductPayload, ListProductPayload
from ..controller.product import ListProduct, CreateProduct, GetProductByBarCode
from typing import Optional
from fastapi import APIRouter, Depends, Request
from ..controller.product import CreateProduct, GetProductByBarCode, ListProduct
from ..model.product import CreateProductPayload, ListProductPayload, Product
router = APIRouter(tags=["product"])

View file

@ -1,9 +1,10 @@
from fastapi import APIRouter, Depends, Request
from ..model.token import Token, RefreshTokenPayload
from ..controller.token import CreateToken, RefreshToken
from fastapi.security import OAuth2PasswordRequestForm
from typing import Annotated
from fastapi import APIRouter, Depends, Request
from fastapi.security import OAuth2PasswordRequestForm
from ..controller.token import CreateToken, RefreshToken
from ..model.token import RefreshTokenPayload, Token
router = APIRouter(tags=["token"])

View file

@ -1,7 +1,7 @@
from fastapi import APIRouter, Depends, Request
from ..model.user import User, CreateUserPayload
from ..controller.user import CreateUser
from ..controller.user import CreateUser
from ..model.user import CreateUserPayload, User
router = APIRouter(tags=["user"])