fix: ruff lint + format fixes in tests, ESLint fixes in frontend

This commit is contained in:
2026-07-17 21:28:58 +02:00
parent 341d0c6f38
commit fbb1b39b57
56 changed files with 1399 additions and 721 deletions
+54 -35
View File
@@ -56,46 +56,67 @@ class Contact(Base):
default=uuid.uuid4,
)
company_name: Mapped[str] = mapped_column(
String(255), nullable=False, index=True,
String(255),
nullable=False,
index=True,
)
legal_form: Mapped[str | None] = mapped_column(
String(50), nullable=True,
String(50),
nullable=True,
)
address_street: Mapped[str | None] = mapped_column(
String(255), nullable=True,
String(255),
nullable=True,
)
address_zip: Mapped[str | None] = mapped_column(
String(10), nullable=True,
String(10),
nullable=True,
)
address_city: Mapped[str | None] = mapped_column(
String(100), nullable=True,
String(100),
nullable=True,
)
address_country: Mapped[str] = mapped_column(
String(2), nullable=False, default="DE", index=True,
String(2),
nullable=False,
default="DE",
index=True,
)
vat_id: Mapped[str | None] = mapped_column(
String(20), nullable=True,
String(20),
nullable=True,
)
phone: Mapped[str | None] = mapped_column(
String(50), nullable=True,
String(50),
nullable=True,
)
email: Mapped[str | None] = mapped_column(
String(255), nullable=True,
String(255),
nullable=True,
)
website: Mapped[str | None] = mapped_column(
String(255), nullable=True,
String(255),
nullable=True,
)
role: Mapped[str] = mapped_column(
String(20), nullable=False, index=True,
String(20),
nullable=False,
index=True,
)
vat_id_status: Mapped[str] = mapped_column(
String(20), nullable=False, default="ungeprueft",
String(20),
nullable=False,
default="ungeprueft",
)
is_private: Mapped[bool] = mapped_column(
Boolean, nullable=False, default=False,
Boolean,
nullable=False,
default=False,
)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, server_default=func.now(),
DateTime(timezone=True),
nullable=False,
server_default=func.now(),
)
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
@@ -104,7 +125,9 @@ class Contact(Base):
onupdate=func.now(),
)
deleted_at: Mapped[datetime | None] = mapped_column(
DateTime(timezone=True), nullable=True, index=True,
DateTime(timezone=True),
nullable=True,
index=True,
)
contact_persons: Mapped[list["ContactPerson"]] = relationship(
@@ -133,18 +156,10 @@ class Contact(Base):
"role": self.role,
"vat_id_status": self.vat_id_status,
"is_private": self.is_private,
"created_at": (
self.created_at.isoformat() if self.created_at else None
),
"updated_at": (
self.updated_at.isoformat() if self.updated_at else None
),
"deleted_at": (
self.deleted_at.isoformat() if self.deleted_at else None
),
"contact_persons": [
p.to_dict() for p in (self.contact_persons or [])
],
"created_at": (self.created_at.isoformat() if self.created_at else None),
"updated_at": (self.updated_at.isoformat() if self.updated_at else None),
"deleted_at": (self.deleted_at.isoformat() if self.deleted_at else None),
"contact_persons": [p.to_dict() for p in (self.contact_persons or [])],
}
@@ -165,19 +180,25 @@ class ContactPerson(Base):
index=True,
)
name: Mapped[str] = mapped_column(
String(255), nullable=False,
String(255),
nullable=False,
)
function: Mapped[str | None] = mapped_column(
String(100), nullable=True,
String(100),
nullable=True,
)
phone: Mapped[str | None] = mapped_column(
String(50), nullable=True,
String(50),
nullable=True,
)
email: Mapped[str | None] = mapped_column(
String(255), nullable=True,
String(255),
nullable=True,
)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, server_default=func.now(),
DateTime(timezone=True),
nullable=False,
server_default=func.now(),
)
contact: Mapped["Contact"] = relationship(back_populates="contact_persons")
@@ -194,7 +215,5 @@ class ContactPerson(Base):
"function": self.function,
"phone": self.phone,
"email": self.email,
"created_at": (
self.created_at.isoformat() if self.created_at else None
),
"created_at": (self.created_at.isoformat() if self.created_at else None),
}
+22 -7
View File
@@ -16,6 +16,7 @@ from app.database import Base
class CopilotRole(str, enum.Enum):
"""Roles for chat messages."""
user = "user"
assistant = "assistant"
@@ -37,10 +38,14 @@ class CopilotSession(Base):
index=True,
)
title: Mapped[str] = mapped_column(
String(255), nullable=False, default="Neue Konversation",
String(255),
nullable=False,
default="Neue Konversation",
)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, server_default=func.now(),
DateTime(timezone=True),
nullable=False,
server_default=func.now(),
)
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
@@ -57,7 +62,9 @@ class CopilotSession(Base):
)
def __repr__(self) -> str:
return f"<CopilotSession id={self.id} user_id={self.user_id} title={self.title}>"
return (
f"<CopilotSession id={self.id} user_id={self.user_id} title={self.title}>"
)
def to_dict(self) -> dict:
"""Serialize session for API responses."""
@@ -99,16 +106,22 @@ class CopilotChat(Base):
)
content: Mapped[str] = mapped_column(Text, nullable=False)
actions: Mapped[list | None] = mapped_column(
JSONB, nullable=True, default=None,
JSONB,
nullable=True,
default=None,
)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, server_default=func.now(),
DateTime(timezone=True),
nullable=False,
server_default=func.now(),
)
session: Mapped["CopilotSession"] = relationship(back_populates="messages")
def __repr__(self) -> str:
return f"<CopilotChat id={self.id} role={self.role} session_id={self.session_id}>"
return (
f"<CopilotChat id={self.id} role={self.role} session_id={self.session_id}>"
)
def to_dict(self) -> dict:
"""Serialize chat message for API responses."""
@@ -116,7 +129,9 @@ class CopilotChat(Base):
"id": str(self.id),
"session_id": str(self.session_id),
"user_id": str(self.user_id),
"role": self.role.value if isinstance(self.role, CopilotRole) else self.role,
"role": self.role.value
if isinstance(self.role, CopilotRole)
else self.role,
"content": self.content,
"actions": self.actions,
"created_at": self.created_at.isoformat() if self.created_at else None,
+1 -3
View File
@@ -23,9 +23,7 @@ class DATEVExport(Base):
)
start_date: Mapped[date] = mapped_column(Date, nullable=False)
end_date: Mapped[date] = mapped_column(Date, nullable=False)
file_path: Mapped[str | None] = mapped_column(
String(500), nullable=True
)
file_path: Mapped[str | None] = mapped_column(String(500), nullable=True)
total_amount: Mapped[Decimal] = mapped_column(
Numeric(14, 2), nullable=False, default=0
)
+9 -27
View File
@@ -30,24 +30,12 @@ class File(Base):
nullable=False,
index=True,
)
original_filename: Mapped[str] = mapped_column(
String(255), nullable=False
)
stored_filename: Mapped[str] = mapped_column(
String(255), nullable=False
)
file_path: Mapped[str] = mapped_column(
String(512), nullable=False
)
mime_type: Mapped[str] = mapped_column(
String(100), nullable=False
)
file_size: Mapped[int] = mapped_column(
Integer, nullable=False
)
thumbnail_path: Mapped[str | None] = mapped_column(
String(512), nullable=True
)
original_filename: Mapped[str] = mapped_column(String(255), nullable=False)
stored_filename: Mapped[str] = mapped_column(String(255), nullable=False)
file_path: Mapped[str] = mapped_column(String(512), nullable=False)
mime_type: Mapped[str] = mapped_column(String(100), nullable=False)
file_size: Mapped[int] = mapped_column(Integer, nullable=False)
thumbnail_path: Mapped[str | None] = mapped_column(String(512), nullable=True)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
nullable=False,
@@ -60,9 +48,7 @@ class File(Base):
onupdate=func.now(),
)
vehicle: Mapped["Vehicle"] = relationship(
"Vehicle", back_populates="files"
)
vehicle: Mapped["Vehicle"] = relationship("Vehicle", back_populates="files")
def __repr__(self) -> str:
return f"<File id={self.id} vehicle_id={self.vehicle_id} filename={self.original_filename}>"
@@ -78,10 +64,6 @@ class File(Base):
"mime_type": self.mime_type,
"file_size": self.file_size,
"thumbnail_path": self.thumbnail_path,
"created_at": (
self.created_at.isoformat() if self.created_at else None
),
"updated_at": (
self.updated_at.isoformat() if self.updated_at else None
),
"created_at": (self.created_at.isoformat() if self.created_at else None),
"updated_at": (self.updated_at.isoformat() if self.updated_at else None),
}
+6 -2
View File
@@ -38,7 +38,9 @@ class OCRResult(Base):
)
file_path: Mapped[str] = mapped_column(String(512), nullable=False)
file_name: Mapped[str] = mapped_column(String(255), nullable=False)
mime_type: Mapped[str] = mapped_column(String(100), nullable=False, default="image/png")
mime_type: Mapped[str] = mapped_column(
String(100), nullable=False, default="image/png"
)
status: Mapped[str] = mapped_column(
Enum(OCRStatus, name="ocr_status", create_constraint=True),
nullable=False,
@@ -80,7 +82,9 @@ class OCRResult(Base):
"file_path": self.file_path,
"file_name": self.file_name,
"mime_type": self.mime_type,
"status": self.status.value if isinstance(self.status, OCRStatus) else str(self.status),
"status": self.status.value
if isinstance(self.status, OCRStatus)
else str(self.status),
"raw_text": self.raw_text,
"structured_data": self.structured_data,
"confidence_score": self.confidence_score,
+7 -21
View File
@@ -38,24 +38,14 @@ class RetouchResult(Base):
nullable=True,
index=True,
)
original_file_path: Mapped[str] = mapped_column(
String(512), nullable=False
)
original_file_name: Mapped[str] = mapped_column(
String(255), nullable=False
)
original_file_path: Mapped[str] = mapped_column(String(512), nullable=False)
original_file_name: Mapped[str] = mapped_column(String(255), nullable=False)
mime_type: Mapped[str] = mapped_column(
String(100), nullable=False, default="image/png"
)
retouched_file_path: Mapped[str | None] = mapped_column(
String(512), nullable=True
)
status: Mapped[str] = mapped_column(
String(20), nullable=False, default="pending"
)
error_message: Mapped[str | None] = mapped_column(
Text, nullable=True
)
retouched_file_path: Mapped[str | None] = mapped_column(String(512), nullable=True)
status: Mapped[str] = mapped_column(String(20), nullable=False, default="pending")
error_message: Mapped[str | None] = mapped_column(Text, nullable=True)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
nullable=False,
@@ -84,10 +74,6 @@ class RetouchResult(Base):
"retouched_file_path": self.retouched_file_path,
"status": self.status,
"error_message": self.error_message,
"created_at": (
self.created_at.isoformat() if self.created_at else None
),
"updated_at": (
self.updated_at.isoformat() if self.updated_at else None
),
"created_at": (self.created_at.isoformat() if self.created_at else None),
"updated_at": (self.updated_at.isoformat() if self.updated_at else None),
}
+7 -13
View File
@@ -66,21 +66,13 @@ class Sale(Base):
nullable=True,
index=True,
)
sale_price: Mapped[Decimal] = mapped_column(
Numeric(12, 2), nullable=False
)
sale_price: Mapped[Decimal] = mapped_column(Numeric(12, 2), nullable=False)
sale_date: Mapped[date] = mapped_column(
Date, nullable=False, default=func.current_date()
)
status: Mapped[str] = mapped_column(
String(20), nullable=False, default="draft"
)
is_gwg: Mapped[bool] = mapped_column(
Boolean, nullable=False, default=False
)
contract_pdf_path: Mapped[str | None] = mapped_column(
String(500), nullable=True
)
status: Mapped[str] = mapped_column(String(20), nullable=False, default="draft")
is_gwg: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
contract_pdf_path: Mapped[str | None] = mapped_column(String(500), nullable=True)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, server_default=func.now()
)
@@ -115,7 +107,9 @@ class Sale(Base):
"seller_contact_id": (
str(self.seller_contact_id) if self.seller_contact_id else None
),
"sale_price": float(self.sale_price) if self.sale_price is not None else None,
"sale_price": float(self.sale_price)
if self.sale_price is not None
else None,
"sale_date": self.sale_date.isoformat() if self.sale_date else None,
"status": self.status,
"is_gwg": self.is_gwg,
+15 -5
View File
@@ -13,6 +13,7 @@ from app.database import Base
class UserRole(str, enum.Enum):
"""User roles for RBAC."""
admin = "admin"
verkaeufer = "verkaeufer"
buchhaltung = "buchhaltung"
@@ -29,13 +30,18 @@ class User(Base):
default=uuid.uuid4,
)
email: Mapped[str] = mapped_column(
String(255), unique=True, nullable=False, index=True,
String(255),
unique=True,
nullable=False,
index=True,
)
password_hash: Mapped[str] = mapped_column(
String(255), nullable=False,
String(255),
nullable=False,
)
full_name: Mapped[str] = mapped_column(
String(200), nullable=False,
String(200),
nullable=False,
)
role: Mapped[UserRole] = mapped_column(
Enum(UserRole, name="user_role"),
@@ -43,10 +49,14 @@ class User(Base):
default=UserRole.verkaeufer,
)
language: Mapped[str] = mapped_column(
String(5), nullable=False, default="de",
String(5),
nullable=False,
default="de",
)
is_active: Mapped[bool] = mapped_column(
Boolean, nullable=False, default=True,
Boolean,
nullable=False,
default=True,
)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
+13 -39
View File
@@ -56,12 +56,8 @@ class Vehicle(Base):
__tablename__ = "vehicles"
__table_args__ = (
CheckConstraint(
"char_length(fin) = 17", name="ck_vehicles_fin_length"
),
CheckConstraint(
"condition IN ('new', 'used')", name="ck_vehicles_condition"
),
CheckConstraint("char_length(fin) = 17", name="ck_vehicles_fin_length"),
CheckConstraint("condition IN ('new', 'used')", name="ck_vehicles_condition"),
CheckConstraint(
"availability IN ('available', 'reserved', 'sold')",
name="ck_vehicles_availability",
@@ -87,24 +83,18 @@ class Vehicle(Base):
String(17), unique=True, nullable=False, index=True
)
year: Mapped[int | None] = mapped_column(Integer, nullable=True)
first_registration: Mapped[date | None] = mapped_column(
Date, nullable=True
)
first_registration: Mapped[date | None] = mapped_column(Date, nullable=True)
power_kw: Mapped[int | None] = mapped_column(Integer, nullable=True)
power_hp: Mapped[int | None] = mapped_column(Integer, nullable=True)
fuel_type: Mapped[str | None] = mapped_column(String(50), nullable=True)
transmission: Mapped[str | None] = mapped_column(String(20), nullable=True)
color: Mapped[str | None] = mapped_column(String(50), nullable=True)
condition: Mapped[str] = mapped_column(
String(20), nullable=False, default="used"
)
condition: Mapped[str] = mapped_column(String(20), nullable=False, default="used")
location: Mapped[str | None] = mapped_column(String(255), nullable=True)
availability: Mapped[str] = mapped_column(
String(20), nullable=False, default="available"
)
price: Mapped[Decimal] = mapped_column(
Numeric(12, 2), nullable=False
)
price: Mapped[Decimal] = mapped_column(Numeric(12, 2), nullable=False)
vehicle_type: Mapped[str] = mapped_column(String(20), nullable=False)
lkw_type: Mapped[str | None] = mapped_column(String(50), nullable=True)
machine_type: Mapped[str | None] = mapped_column(String(50), nullable=True)
@@ -112,9 +102,7 @@ class Vehicle(Base):
operating_hours: Mapped[Decimal | None] = mapped_column(
Numeric(12, 1), nullable=True
)
operating_hours_unit: Mapped[str | None] = mapped_column(
String(5), nullable=True
)
operating_hours_unit: Mapped[str | None] = mapped_column(String(5), nullable=True)
mileage_km: Mapped[int | None] = mapped_column(Integer, nullable=True)
description: Mapped[str | None] = mapped_column(Text, nullable=True)
created_at: Mapped[datetime] = mapped_column(
@@ -149,9 +137,7 @@ class Vehicle(Base):
"fin": self.fin,
"year": self.year,
"first_registration": (
self.first_registration.isoformat()
if self.first_registration
else None
self.first_registration.isoformat() if self.first_registration else None
),
"power_kw": self.power_kw,
"power_hp": self.power_hp,
@@ -174,15 +160,9 @@ class Vehicle(Base):
"operating_hours_unit": self.operating_hours_unit,
"mileage_km": self.mileage_km,
"description": self.description,
"created_at": (
self.created_at.isoformat() if self.created_at else None
),
"updated_at": (
self.updated_at.isoformat() if self.updated_at else None
),
"deleted_at": (
self.deleted_at.isoformat() if self.deleted_at else None
),
"created_at": (self.created_at.isoformat() if self.created_at else None),
"updated_at": (self.updated_at.isoformat() if self.updated_at else None),
"deleted_at": (self.deleted_at.isoformat() if self.deleted_at else None),
}
@@ -232,14 +212,8 @@ class MobileDeListing(Base):
"vehicle_id": str(self.vehicle_id),
"ad_id": self.ad_id,
"sync_status": self.sync_status,
"synced_at": (
self.synced_at.isoformat() if self.synced_at else None
),
"synced_at": (self.synced_at.isoformat() if self.synced_at else None),
"error_log": self.error_log,
"created_at": (
self.created_at.isoformat() if self.created_at else None
),
"updated_at": (
self.updated_at.isoformat() if self.updated_at else None
),
"created_at": (self.created_at.isoformat() if self.created_at else None),
"updated_at": (self.updated_at.isoformat() if self.updated_at else None),
}