fix pylint errors
Some checks failed
Deploy Amap / deploy (push) Failing after 16s

This commit is contained in:
Julien Aldon
2026-03-03 11:08:08 +01:00
parent 0e48d1bbaa
commit 8352097ffb
60 changed files with 1288 additions and 612 deletions

View File

@@ -1,12 +1,13 @@
from sqlmodel import Session, select
import src.models as models
import src.productors.exceptions as exceptions
import src.messages as messages
import src.productors.exceptions as exceptions
from sqlmodel import Session, select
from src import models
def get_all(
session: Session,
user: models.User,
names: list[str],
user: models.User,
names: list[str],
types: list[str]
) -> list[models.ProductorPublic]:
statement = select(models.Productor)\
@@ -18,13 +19,20 @@ def get_all(
statement = statement.where(models.Productor.type.in_(types))
return session.exec(statement.order_by(models.Productor.name)).all()
def get_one(session: Session, productor_id: int) -> models.ProductorPublic:
return session.get(models.Productor, productor_id)
def create_one(session: Session, productor: models.ProductorCreate) -> models.ProductorPublic:
def create_one(
session: Session,
productor: models.ProductorCreate) -> models.ProductorPublic:
if not productor:
raise exceptions.ProductorCreateError(messages.Messages.invalid_input('productor', 'input cannot be None'))
productor_create = productor.model_dump(exclude_unset=True, exclude='payment_methods')
raise exceptions.ProductorCreateError(
messages.Messages.invalid_input(
'productor', 'input cannot be None'))
productor_create = productor.model_dump(
exclude_unset=True, exclude='payment_methods')
new_productor = models.Productor(**productor_create)
new_productor.payment_methods = [
@@ -39,13 +47,18 @@ def create_one(session: Session, productor: models.ProductorCreate) -> models.Pr
session.refresh(new_productor)
return new_productor
def update_one(session: Session, id: int, productor: models.ProductorUpdate) -> models.ProductorPublic:
def update_one(
session: Session,
id: int,
productor: models.ProductorUpdate) -> models.ProductorPublic:
statement = select(models.Productor).where(models.Productor.id == id)
result = session.exec(statement)
new_productor = result.first()
if not new_productor:
raise exceptions.ProductorNotFoundError(messages.Messages.not_found('productor'))
raise exceptions.ProductorNotFoundError(
messages.Messages.not_found('productor'))
productor_updates = productor.model_dump(exclude_unset=True)
if 'payment_methods' in productor_updates:
new_productor.payment_methods.clear()
@@ -67,12 +80,14 @@ def update_one(session: Session, id: int, productor: models.ProductorUpdate) ->
session.refresh(new_productor)
return new_productor
def delete_one(session: Session, id: int) -> models.ProductorPublic:
statement = select(models.Productor).where(models.Productor.id == id)
result = session.exec(statement)
productor = result.first()
if not productor:
raise exceptions.ProductorNotFoundError(messages.Messages.not_found('productor'))
raise exceptions.ProductorNotFoundError(
messages.Messages.not_found('productor'))
result = models.ProductorPublic.model_validate(productor)
session.delete(productor)
session.commit()