Ruff fixes

This commit is contained in:
Donkie
2023-05-28 22:55:11 +02:00
parent 639f91bd49
commit 235236d435
8 changed files with 8 additions and 8 deletions

View File

@@ -132,7 +132,7 @@ class Spool(BaseModel):
def from_db(item: models.Spool) -> "Spool":
"""Create a new Pydantic spool object from a database spool object."""
filament = Filament.from_db(item.filament)
remaining_weight: Optional[float] = None
remaining_weight: float | None = None
if filament.weight is not None:
remaining_weight = max(filament.weight - item.used_weight, 0)

View File

@@ -28,7 +28,7 @@ async def create(
settings_bed_temp: Optional[int] = None,
) -> models.Filament:
"""Add a new filament to the database."""
vendor_item: Optional[models.Vendor] = None
vendor_item: models.Vendor | None = None
if vendor_id is not None:
vendor_item = await vendor.get_by_id(db, vendor_id)

View File

@@ -41,7 +41,6 @@ class Filament(Base):
comment: Mapped[Optional[str]] = mapped_column(String(1024))
settings_extruder_temp: Mapped[Optional[int]] = mapped_column(comment="Overridden extruder temperature.")
settings_bed_temp: Mapped[Optional[int]] = mapped_column(comment="Overridden bed temperature.")
# TODO: Color?
class Spool(Base):

View File

@@ -139,7 +139,6 @@ async def use_weight_safe(db: AsyncSession, spool_id: int, weight: float) -> Non
)
# TODO: Make unit tests for race conditions on these
async def use_weight(db: AsyncSession, spool_id: int, weight: float) -> models.Spool:
"""Consume filament from a spool by weight.

View File

@@ -90,7 +90,7 @@ async def startup() -> None:
# There is some issue with the uvicorn worker that causes the process to hang when running alembic directly.
# See: https://github.com/sqlalchemy/alembic/discussions/1155
project_root = Path(__file__).parent.parent
subprocess.run(["alembic", "upgrade", "head"], check=True, cwd=project_root) # noqa: S603, S607
subprocess.run(["alembic", "upgrade", "head"], check=True, cwd=project_root) # noqa: S603, S607, ASYNC101
logger.info("Startup complete.")