From 2c086dd91ada7511357bcd514c5c232aee5f9355 Mon Sep 17 00:00:00 2001 From: bambuman Date: Thu, 5 Feb 2026 18:49:34 +0200 Subject: [PATCH] ruff format changes --- backend/app/api/routes/spoolman.py | 4 +++- backend/app/core/database.py | 1 + backend/app/main.py | 11 +++-------- backend/tests/unit/services/test_spoolman_service.py | 4 +--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/backend/app/api/routes/spoolman.py b/backend/app/api/routes/spoolman.py index ddcacf7d2..eeaf135b7 100644 --- a/backend/app/api/routes/spoolman.py +++ b/backend/app/api/routes/spoolman.py @@ -252,7 +252,9 @@ async def sync_printer_ams( current_tray_uuids.add(spool_tag.upper()) try: - sync_result = await client.sync_ams_tray(tray, printer.name, disable_weight_sync=disable_weight_sync) + sync_result = await client.sync_ams_tray( + tray, printer.name, disable_weight_sync=disable_weight_sync + ) if sync_result: synced += 1 logger.info(f"Synced {tray.tray_sub_brands} from {printer.name} AMS {ams_id} tray {tray.tray_id}") diff --git a/backend/app/core/database.py b/backend/app/core/database.py index bfb8d4b5b..ce7d44dd7 100644 --- a/backend/app/core/database.py +++ b/backend/app/core/database.py @@ -1101,6 +1101,7 @@ async def run_migrations(conn): except Exception: pass + async def seed_notification_templates(): """Seed default notification templates if they don't exist.""" from sqlalchemy import select diff --git a/backend/app/main.py b/backend/app/main.py index eb571c877..8d69c5e4d 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -527,8 +527,7 @@ async def _report_partial_spoolman_usage(printer_id: int, tracking, logger): # Convert string keys back to int (JSON serialization issue) # Both outer (layer) and inner (filament_id) keys need conversion layer_usage_int = { - int(layer): {int(fid): mm for fid, mm in filaments.items()} - for layer, filaments in layer_usage.items() + int(layer): {int(fid): mm for fid, mm in filaments.items()} for layer, filaments in layer_usage.items() } # Get cumulative usage at current layer @@ -558,9 +557,7 @@ async def _report_partial_spoolman_usage(printer_id: int, tracking, logger): tray_uuid = tray_info.get("tray_uuid", "") tag_uid = tray_info.get("tag_uid", "") spool_tag = ( - tray_uuid - if tray_uuid and tray_uuid != "00000000000000000000000000000000" - else tag_uid + tray_uuid if tray_uuid and tray_uuid != "00000000000000000000000000000000" else tag_uid ) if not spool_tag: @@ -639,9 +636,7 @@ async def _report_partial_spoolman_usage(printer_id: int, tracking, logger): tray_uuid = tray_info.get("tray_uuid", "") tag_uid = tray_info.get("tag_uid", "") spool_tag = ( - tray_uuid - if tray_uuid and tray_uuid != "00000000000000000000000000000000" - else tag_uid + tray_uuid if tray_uuid and tray_uuid != "00000000000000000000000000000000" else tag_uid ) if not spool_tag: diff --git a/backend/tests/unit/services/test_spoolman_service.py b/backend/tests/unit/services/test_spoolman_service.py index bbb645ce1..7f76c46b3 100644 --- a/backend/tests/unit/services/test_spoolman_service.py +++ b/backend/tests/unit/services/test_spoolman_service.py @@ -87,9 +87,7 @@ class TestSpoolmanClient: assert "TestPrinter" in call_kwargs["location"] @pytest.mark.asyncio - async def test_sync_ams_tray_new_spool_always_includes_weight( - self, client, sample_tray, mock_filament - ): + async def test_sync_ams_tray_new_spool_always_includes_weight(self, client, sample_tray, mock_filament): """Verify new spool creation always includes remaining_weight even when disabled.""" with ( patch.object(client, "find_spool_by_tag", AsyncMock(return_value=None)),