From e2ce1d8b240c59cfd1c0e4bc888cdef833a2400a Mon Sep 17 00:00:00 2001 From: jan iversen Date: Tue, 24 Aug 2021 11:28:45 +0200 Subject: [PATCH] Please mypy in gtfs and implement needed changes (#54328) --- homeassistant/components/gtfs/sensor.py | 10 +++++----- mypy.ini | 3 --- script/hassfest/mypy_config.py | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/gtfs/sensor.py b/homeassistant/components/gtfs/sensor.py index f8f89b1ea36d..138fdd96b896 100644 --- a/homeassistant/components/gtfs/sensor.py +++ b/homeassistant/components/gtfs/sensor.py @@ -255,7 +255,7 @@ WHEELCHAIR_BOARDING_DEFAULT = STATE_UNKNOWN WHEELCHAIR_BOARDING_OPTIONS = {1: True, 2: False} PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( - { # type: ignore + { vol.Required(CONF_ORIGIN): cv.string, vol.Required(CONF_DESTINATION): cv.string, vol.Required(CONF_DATA): cv.string, @@ -490,7 +490,7 @@ def setup_platform( origin = config.get(CONF_ORIGIN) destination = config.get(CONF_DESTINATION) name = config.get(CONF_NAME) - offset = config.get(CONF_OFFSET) + offset = datetime.timedelta(seconds=float(config.get(CONF_OFFSET, 0))) include_tomorrow = config[CONF_TOMORROW] if not os.path.exists(gtfs_dir): @@ -541,10 +541,10 @@ class GTFSDepartureSensor(SensorEntity): self._icon = ICON self._name = "" self._state: str | None = None - self._attributes = {} + self._attributes: dict[str, float | str] = {} self._agency = None - self._departure = {} + self._departure: dict[str, Any] = {} self._destination = None self._origin = None self._route = None @@ -559,7 +559,7 @@ class GTFSDepartureSensor(SensorEntity): return self._name @property - def native_value(self) -> str | None: # type: ignore + def native_value(self) -> str | None: """Return the state of the sensor.""" return self._state diff --git a/mypy.ini b/mypy.ini index e566b7f1898a..82ed7d6ae9d3 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1355,9 +1355,6 @@ ignore_errors = true [mypy-homeassistant.components.growatt_server.*] ignore_errors = true -[mypy-homeassistant.components.gtfs.*] -ignore_errors = true - [mypy-homeassistant.components.habitica.*] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index bb2cf72b72e2..581b4865f7ce 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -44,7 +44,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.gpmdp.*", "homeassistant.components.gree.*", "homeassistant.components.growatt_server.*", - "homeassistant.components.gtfs.*", "homeassistant.components.habitica.*", "homeassistant.components.harmony.*", "homeassistant.components.hassio.*",