Skip to content

Commit

Permalink
Fix errori mypy (compatibili con ruff)
Browse files Browse the repository at this point in the history
  • Loading branch information
virtualdj committed Nov 2, 2024
1 parent ea274d5 commit 84a865b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/pun_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def async_setup_entry(hass: HomeAssistant, config: ConfigEntry) -> bool:
# Carica le dipendenze di holidays in background per evitare errori nel log
if AwesomeVersion(HA_VERSION) >= AwesomeVersion("2024.5.0"):
with async_pause_setup(hass, SetupPhases.WAIT_IMPORT_PACKAGES):
await hass.async_add_import_executor_job(holidays.IT)
await hass.async_add_import_executor_job(holidays.IT) # type: ignore[attr-defined]

# Salva il coordinator nella configurazione
coordinator = PUNDataUpdateCoordinator(hass, config)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/pun_sensor/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, entry: config_entries.ConfigEntry) -> None:

async def async_step_init(self, user_input=None) -> FlowResult:
"""Gestisce le opzioni."""
errors = {}
errors: dict[str, str] | None = {}
if user_input is not None:
# Configurazione valida (validazione integrata nello schema)
return self.async_create_entry(title="PUN", data=user_input)
Expand Down
3 changes: 2 additions & 1 deletion custom_components/pun_sensor/sensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Implementazione sensori di pun_sensor."""

# pylint: disable=global-variable-undefined,overridden-final-method
from typing import Any

from awesomeversion.awesomeversion import AwesomeVersion
Expand Down Expand Up @@ -47,7 +48,7 @@ async def async_setup_entry(
)

# Crea i sensori dei valori del pun (legati al coordinator)
entities = []
entities: list[SensorEntity] = []
entities.extend(
PUNSensorEntity(coordinator, fascia) for fascia in PunValues().value
)
Expand Down
8 changes: 4 additions & 4 deletions custom_components/pun_sensor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
from zipfile import ZipFile

import defusedxml.ElementTree as et
import defusedxml.ElementTree as et # type: ignore[import-untyped]
import holidays

from .interfaces import Fascia, PunData
Expand Down Expand Up @@ -41,7 +41,7 @@ def get_fascia(dataora: datetime) -> tuple[Fascia, datetime]:
"""Restituisce la fascia della data/ora indicata e la data del prossimo cambiamento."""

# Verifica se la data corrente è un giorno con festività
festivo = dataora in holidays.IT()
festivo = dataora in holidays.IT() # type: ignore[attr-defined]

# Identifica la fascia corrente
# F1 = lu-ve 8-19
Expand Down Expand Up @@ -135,7 +135,7 @@ def get_next_date(
)

if feriale:
while (prossima in holidays.IT()) or (prossima.weekday() == 6):
while (prossima in holidays.IT()) or (prossima.weekday() == 6): # type: ignore[attr-defined]
prossima += timedelta(days=1)

return prossima
Expand All @@ -149,7 +149,7 @@ def extract_xml(archive: ZipFile, pun_data: PunData) -> PunData:
"""
# Carica le festività
it_holidays = holidays.IT()
it_holidays = holidays.IT() # type: ignore[attr-defined]

# Esamina ogni file XML nello ZIP (ordinandoli prima)
for fn in sorted(archive.namelist()):
Expand Down

0 comments on commit 84a865b

Please sign in to comment.