mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-04-07 08:03:40 +00:00
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:
parent
a010ccd290
commit
76baee7623
1 changed files with 0 additions and 5 deletions
|
|
@ -217,11 +217,6 @@ def group_periods_by_day(periods: list[dict]) -> dict[date, list[dict]]:
|
||||||
while current_date <= end_date:
|
while current_date <= end_date:
|
||||||
periods_by_day.setdefault(current_date, []).append(period)
|
periods_by_day.setdefault(current_date, []).append(period)
|
||||||
# Move to next day
|
# 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(
|
def mark_periods_with_relaxation(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue