From 29b45895c18e9dc573997af118c47df308340ae4 Mon Sep 17 00:00:00 2001 From: aurex-ml Date: Thu, 14 May 2026 16:47:53 +0300 Subject: [PATCH 1/2] style: apply Black formatting --- scripts/run_simulation.py | 6 +++--- src/core/derms_engine.py | 4 +--- src/services/grid_interface.py | 4 +--- tests/unit/test_forecaster.py | 10 ++++++---- tests/unit/test_optimizer.py | 9 +++++++-- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/scripts/run_simulation.py b/scripts/run_simulation.py index d7eb9da..72990cc 100644 --- a/scripts/run_simulation.py +++ b/scripts/run_simulation.py @@ -73,9 +73,9 @@ def generate_synthetic_resources(n: int, rng: random.Random) -> list[dict]: "type": res_type, "site_id": f"site-{i % 3}", "capacity_kw": round(rng.uniform(50.0, 500.0), 1), - "state_of_charge": round(rng.uniform(0.2, 0.8), 2) - if res_type == "battery" - else None, + "state_of_charge": ( + round(rng.uniform(0.2, 0.8), 2) if res_type == "battery" else None + ), } ) return resources diff --git a/src/core/derms_engine.py b/src/core/derms_engine.py index 615732d..e63cc7f 100644 --- a/src/core/derms_engine.py +++ b/src/core/derms_engine.py @@ -86,9 +86,7 @@ async def list_resources( resources = [r for r in resources if r.get("site_id") == site_id] return resources[offset : offset + limit] - async def get_resource_status( - self, resource_id: str - ) -> dict[str, Any] | None: + async def get_resource_status(self, resource_id: str) -> dict[str, Any] | None: """Return the latest telemetry snapshot for a DER. In production this reads from the Redis cache populated by the diff --git a/src/services/grid_interface.py b/src/services/grid_interface.py index 03271bf..0dba981 100644 --- a/src/services/grid_interface.py +++ b/src/services/grid_interface.py @@ -33,9 +33,7 @@ def __init__(self) -> None: extra={"endpoint": self.endpoint, "simulation": self.simulation_mode}, ) - async def submit_dispatch_schedule( - self, schedule: list[dict[str, Any]] - ) -> bool: + async def submit_dispatch_schedule(self, schedule: list[dict[str, Any]]) -> bool: """Submit an aggregated dispatch schedule to the grid operator. Args: diff --git a/tests/unit/test_forecaster.py b/tests/unit/test_forecaster.py index 9d99743..944ded5 100644 --- a/tests/unit/test_forecaster.py +++ b/tests/unit/test_forecaster.py @@ -4,7 +4,11 @@ import pytest -from src.models.load_forecaster import ForecastPoint, LoadForecast, generate_dummy_forecast +from src.models.load_forecaster import ( + ForecastPoint, + LoadForecast, + generate_dummy_forecast, +) class TestForecastPoint: @@ -59,9 +63,7 @@ def test_timestamps_are_sequential(self): from datetime import datetime, timezone points = generate_dummy_forecast(horizon_hours=2, interval="1h", seed=0) - timestamps = [ - datetime.fromisoformat(p.timestamp) for p in points - ] + timestamps = [datetime.fromisoformat(p.timestamp) for p in points] deltas = [ (timestamps[i + 1] - timestamps[i]).seconds for i in range(len(timestamps) - 1) diff --git a/tests/unit/test_optimizer.py b/tests/unit/test_optimizer.py index 14ce298..c040370 100644 --- a/tests/unit/test_optimizer.py +++ b/tests/unit/test_optimizer.py @@ -7,7 +7,9 @@ from src.core.optimizer import BatteryOptimizer -def _make_battery_resource(resource_id: str = "bat-001", capacity_kw: float = 100.0) -> dict: +def _make_battery_resource( + resource_id: str = "bat-001", capacity_kw: float = 100.0 +) -> dict: return { "id": resource_id, "type": "battery", @@ -28,7 +30,10 @@ def test_returns_schedule_and_revenue(self): def test_schedule_has_correct_number_of_intervals(self): optimizer = BatteryOptimizer(strategy="heuristic") - resources = [_make_battery_resource("bat-001"), _make_battery_resource("bat-002")] + resources = [ + _make_battery_resource("bat-001"), + _make_battery_resource("bat-002"), + ] result = optimizer.optimize(resources, {"horizon_hours": 12}) # 12 hours × 2 batteries = 24 schedule entries assert len(result["schedule"]) == 24 From 10f1daf41b8a05db77f8940ade01c05c44ad8219 Mon Sep 17 00:00:00 2001 From: Ayiemba Rodgers Date: Thu, 14 May 2026 20:40:00 +0300 Subject: [PATCH 2/2] Potential fix for pull request finding 'CodeQL / Unused import' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Ayiemba Rodgers --- tests/unit/test_forecaster.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/test_forecaster.py b/tests/unit/test_forecaster.py index 944ded5..f13a30d 100644 --- a/tests/unit/test_forecaster.py +++ b/tests/unit/test_forecaster.py @@ -6,7 +6,6 @@ from src.models.load_forecaster import ( ForecastPoint, - LoadForecast, generate_dummy_forecast, )