fix(coordinator): move timedelta import out of while loop

PLC0415 – suppress with noqa was already suppressing the warning, but the
import was still executed on every iteration of the while loop.  Standard
library imports belong at module level both for correctness and performance.

Move 'from datetime import timedelta' to the top-level import block and
remove the now-unnecessary 'noqa: PLC0415' comment.

Impact: Negligible per-call overhead removed.  More importantly, the code
no longer suppresses a linter warning that signals a real anti-pattern;
future static analysis runs will correctly flag any new inline imports.
This commit is contained in:
Julian Pawlowski 2026-04-06 14:09:58 +00:00
parent a010ccd290
commit 76baee7623

View file

@ -217,11 +217,6 @@ def group_periods_by_day(periods: list[dict]) -> dict[date, list[dict]]:
while current_date <= end_date:
periods_by_day.setdefault(current_date, []).append(period)
# Move to next day
from datetime import timedelta # noqa: PLC0415
current_date = current_date + timedelta(days=1)
return periods_by_day
def mark_periods_with_relaxation(