Ruff fixes
This commit is contained in:
@@ -16,7 +16,7 @@ exclude = ["client"]
|
||||
|
||||
[tool.ruff]
|
||||
select = ["ALL"]
|
||||
ignore = ["A003", "D101", "D104", "D406", "D407", "S104", "TRY201", "TRY003", "EM101", "EM102", "DTZ003", "PLR0913"]
|
||||
ignore = ["ANN101", "A003", "D101", "D104", "D203", "D213", "D406", "D407", "S104", "TRY201", "TRY003", "EM101", "EM102", "DTZ003", "PLR0913"]
|
||||
line-length = 120
|
||||
target-version = "py39"
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
ruff==0.0.260
|
||||
black==23.3.0
|
||||
ruff
|
||||
black
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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.")
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"""Build and run the integration tests."""
|
||||
|
||||
# ruff: noqa: S605, S607
|
||||
|
||||
import os
|
||||
|
||||
os.system("docker build -t donkie/spoolman:test .")
|
||||
|
||||
Reference in New Issue
Block a user