🚨 fix some linter warnings
Some checks failed
Python formatting PEP8 / Python-PEP8 (push) Failing after 13s

This commit is contained in:
Finn Christiansen 2023-08-11 22:47:08 +02:00
parent 44b73ab89d
commit a689b1c56d
4 changed files with 28 additions and 38 deletions

View file

@ -7,6 +7,8 @@ from alembic import context
import os import os
import sys import sys
from dotenv import load_dotenv from dotenv import load_dotenv
from app.models import models
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
load_dotenv(os.path.join(BASE_DIR, ".env")) load_dotenv(os.path.join(BASE_DIR, ".env"))
sys.path.append(BASE_DIR) sys.path.append(BASE_DIR)
@ -29,7 +31,6 @@ if config.config_file_name is not None:
# target_metadata = mymodel.Base.metadata # target_metadata = mymodel.Base.metadata
# target_metadata = None # target_metadata = None
from app.models import models
target_metadata = models.Base.metadata target_metadata = models.Base.metadata
# other values from the config, defined by the needs of env.py, # other values from the config, defined by the needs of env.py,

View file

@ -1,6 +1,3 @@
from fastapi import HTTPException
from sqlalchemy.orm import Session
from models import Item from models import Item
from schemas.schemas import ItemCreate, ItemUpdate from schemas.schemas import ItemCreate, ItemUpdate
from crud.base import CRUDBase from crud.base import CRUDBase
@ -8,33 +5,6 @@ from crud.base import CRUDBase
class CRUDItem(CRUDBase[Item, ItemCreate, ItemUpdate]): class CRUDItem(CRUDBase[Item, ItemCreate, ItemUpdate]):
pass pass
# def get_item(self, db: Session, item_id: int):
# item = db.query(Item).filter(Item.id == item_id).first()
# if not item:
# raise HTTPException(status_code=404, detail="Item not found")
# return item
# def get_items(self, db: Session, skip: int = 0, limit: int = 100):
# return db.query(Item).offset(skip).limit(limit).all()
# def create_item(self, db: Session, item: ItemCreate):
# db_item = Item(title=item.title, description=item.description)
# db.add(db_item)
# db.commit()
# db.refresh(db_item)
# return db_item
# def update_item(self, db: Session, item: ItemUpdate):
# db_item = Item(title=item.title, description=item.description)
# db.add(db_item)
# db.commit()
# db.refresh(db_item)
# return db_item
# def delete_item(self, db: Session, item_id: int):
# db.query(Item).filter(Item.id == item_id).first().delete()
# db.commit()
# return
item = CRUDItem(Item) item = CRUDItem(Item)

View file

@ -27,25 +27,44 @@ async def root():
@app.get("/items/{item_id}", response_model=schemas.Item) @app.get("/items/{item_id}", response_model=schemas.Item)
async def get_item(*, db: Session = Depends(get_db), item_id: int): async def get_item(
*,
db: Session = Depends(get_db),
item_id: int
):
return crud.item.get(db, item_id) return crud.item.get(db, item_id)
@app.get("/items/", response_model=list[schemas.Item]) @app.get("/items/", response_model=list[schemas.Item])
async def get_items(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)): async def get_items(
skip: int = 0,
limit: int = 100,
db: Session = Depends(get_db)
):
return crud.item.get_multi(db, skip=skip, limit=limit) return crud.item.get_multi(db, skip=skip, limit=limit)
@app.post("/items/", response_model=schemas.Item) @app.post("/items/", response_model=schemas.Item)
async def create_item(item: schemas.ItemCreate, db: Session = Depends(get_db)): async def create_item(
item: schemas.ItemCreate,
db: Session = Depends(get_db)
):
return crud.item.create(db=db, item=item) return crud.item.create(db=db, item=item)
@app.put("/items/{item_id}", response_model=schemas.ItemUpdate) @app.put("/items/{item_id}", response_model=schemas.ItemUpdate)
async def update_item(item: schemas.ItemUpdate, db: Session = Depends(get_db)): async def update_item(
item: schemas.ItemUpdate,
db: Session = Depends(get_db)
):
return crud.item.update(db=db, item=item) return crud.item.update(db=db, item=item)
@app.delete("/items/{item_id}") @app.delete("/items/{item_id}")
async def delete_item(*, item: schemas.ItemUpdate, db: Session = Depends(get_db), item_id: int): async def delete_item(
*,
item: schemas.ItemUpdate,
db: Session = Depends(get_db),
item_id: int
):
return crud.remove(item_id) return crud.remove(item_id)

View file

@ -1,4 +1,4 @@
from sqlalchemy import Boolean, Column, Integer, String from sqlalchemy import Column, Integer, String
from database import Base from database import Base