mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Move imports in gtfs component (#27999)
* Move imports in gtfs component * Fix pylint
This commit is contained in:
parent
ff17bb4a56
commit
3692c7496e
@ -5,6 +5,8 @@ import os
|
|||||||
import threading
|
import threading
|
||||||
from typing import Any, Callable, Optional
|
from typing import Any, Callable, Optional
|
||||||
|
|
||||||
|
import pygtfs
|
||||||
|
from sqlalchemy.sql import text
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
@ -129,8 +131,6 @@ def get_next_departure(
|
|||||||
tomorrow = now + datetime.timedelta(days=1)
|
tomorrow = now + datetime.timedelta(days=1)
|
||||||
tomorrow_date = tomorrow.strftime(dt_util.DATE_STR_FORMAT)
|
tomorrow_date = tomorrow.strftime(dt_util.DATE_STR_FORMAT)
|
||||||
|
|
||||||
from sqlalchemy.sql import text
|
|
||||||
|
|
||||||
# Fetch all departures for yesterday, today and optionally tomorrow,
|
# Fetch all departures for yesterday, today and optionally tomorrow,
|
||||||
# up to an overkill maximum in case of a departure every minute for those
|
# up to an overkill maximum in case of a departure every minute for those
|
||||||
# days.
|
# days.
|
||||||
@ -353,8 +353,6 @@ def setup_platform(
|
|||||||
_LOGGER.error("The given GTFS data file/folder was not found")
|
_LOGGER.error("The given GTFS data file/folder was not found")
|
||||||
return
|
return
|
||||||
|
|
||||||
import pygtfs
|
|
||||||
|
|
||||||
(gtfs_root, _) = os.path.splitext(data)
|
(gtfs_root, _) = os.path.splitext(data)
|
||||||
|
|
||||||
sqlite_file = f"{gtfs_root}.sqlite?check_same_thread=False"
|
sqlite_file = f"{gtfs_root}.sqlite?check_same_thread=False"
|
||||||
@ -375,7 +373,7 @@ class GTFSDepartureSensor(Entity):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
pygtfs: Any,
|
gtfs: Any,
|
||||||
name: Optional[Any],
|
name: Optional[Any],
|
||||||
origin: Any,
|
origin: Any,
|
||||||
destination: Any,
|
destination: Any,
|
||||||
@ -383,7 +381,7 @@ class GTFSDepartureSensor(Entity):
|
|||||||
include_tomorrow: bool,
|
include_tomorrow: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._pygtfs = pygtfs
|
self._pygtfs = gtfs
|
||||||
self.origin = origin
|
self.origin = origin
|
||||||
self.destination = destination
|
self.destination = destination
|
||||||
self._include_tomorrow = include_tomorrow
|
self._include_tomorrow = include_tomorrow
|
||||||
|
Loading…
x
Reference in New Issue
Block a user