From 61edd33da74d75df3e7cd8c26c685be7db8d06c8 Mon Sep 17 00:00:00 2001 From: Quentame Date: Fri, 18 Oct 2019 02:11:51 +0200 Subject: [PATCH] Move imports in google component (#27826) --- homeassistant/components/google/__init__.py | 20 +++++++++----------- homeassistant/components/google/calendar.py | 5 ++--- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/google/__init__.py b/homeassistant/components/google/__init__.py index 62aa2212bb1..9cb9be0fa4f 100644 --- a/homeassistant/components/google/__init__.py +++ b/homeassistant/components/google/__init__.py @@ -4,6 +4,15 @@ import logging import os import yaml +import httplib2 +from oauth2client.client import ( + OAuth2WebServerFlow, + OAuth2DeviceCodeError, + FlowExchangeError, +) +from oauth2client.file import Storage +from googleapiclient import discovery as google_discovery + import voluptuous as vol from voluptuous.error import Error as VoluptuousError @@ -126,13 +135,6 @@ def do_authentication(hass, hass_config, config): Notify user of user_code and verification_url then poll until we have an access token. """ - from oauth2client.client import ( - OAuth2WebServerFlow, - OAuth2DeviceCodeError, - FlowExchangeError, - ) - from oauth2client.file import Storage - oauth = OAuth2WebServerFlow( client_id=config[CONF_CLIENT_ID], client_secret=config[CONF_CLIENT_SECRET], @@ -341,10 +343,6 @@ class GoogleCalendarService: def get(self): """Get the calendar service from the storage file token.""" - import httplib2 - from oauth2client.file import Storage - from googleapiclient import discovery as google_discovery - credentials = Storage(self.token_file).get() http = credentials.authorize(httplib2.Http()) service = google_discovery.build( diff --git a/homeassistant/components/google/calendar.py b/homeassistant/components/google/calendar.py index 31e9f186a4e..8a6eb644621 100644 --- a/homeassistant/components/google/calendar.py +++ b/homeassistant/components/google/calendar.py @@ -3,6 +3,8 @@ import copy from datetime import timedelta import logging +from httplib2 import ServerNotFoundError # pylint: disable=import-error + from homeassistant.components.calendar import ( ENTITY_ID_FORMAT, CalendarEventDevice, @@ -126,9 +128,6 @@ class GoogleCalendarData: self.event = None def _prepare_query(self): - # pylint: disable=import-error - from httplib2 import ServerNotFoundError - try: service = self.calendar_service.get() except ServerNotFoundError: