From 3692c7496e1a3eaa7e67a8639fbe454b4c6dcc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diefferson=20Koderer=20M=C3=B4ro?= Date: Tue, 22 Oct 2019 05:38:33 +0000 Subject: [PATCH] Move imports in gtfs component (#27999) * Move imports in gtfs component * Fix pylint --- homeassistant/components/gtfs/sensor.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/gtfs/sensor.py b/homeassistant/components/gtfs/sensor.py index 086545f0c76..07b450dd33e 100644 --- a/homeassistant/components/gtfs/sensor.py +++ b/homeassistant/components/gtfs/sensor.py @@ -5,6 +5,8 @@ import os import threading from typing import Any, Callable, Optional +import pygtfs +from sqlalchemy.sql import text import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA @@ -129,8 +131,6 @@ def get_next_departure( tomorrow = now + datetime.timedelta(days=1) tomorrow_date = tomorrow.strftime(dt_util.DATE_STR_FORMAT) - from sqlalchemy.sql import text - # Fetch all departures for yesterday, today and optionally tomorrow, # up to an overkill maximum in case of a departure every minute for those # days. @@ -353,8 +353,6 @@ def setup_platform( _LOGGER.error("The given GTFS data file/folder was not found") return - import pygtfs - (gtfs_root, _) = os.path.splitext(data) sqlite_file = f"{gtfs_root}.sqlite?check_same_thread=False" @@ -375,7 +373,7 @@ class GTFSDepartureSensor(Entity): def __init__( self, - pygtfs: Any, + gtfs: Any, name: Optional[Any], origin: Any, destination: Any, @@ -383,7 +381,7 @@ class GTFSDepartureSensor(Entity): include_tomorrow: bool, ) -> None: """Initialize the sensor.""" - self._pygtfs = pygtfs + self._pygtfs = gtfs self.origin = origin self.destination = destination self._include_tomorrow = include_tomorrow