From 6998687742943c5e6e2d0f068fb855d657e4cbb8 Mon Sep 17 00:00:00 2001 From: Quentame Date: Fri, 18 Oct 2019 02:11:20 +0200 Subject: [PATCH] Move imports in gitlab_ci component (#27827) --- homeassistant/components/gitlab_ci/sensor.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/gitlab_ci/sensor.py b/homeassistant/components/gitlab_ci/sensor.py index d8055c88f30..9edbe9733a8 100644 --- a/homeassistant/components/gitlab_ci/sensor.py +++ b/homeassistant/components/gitlab_ci/sensor.py @@ -2,6 +2,7 @@ from datetime import timedelta import logging +from gitlab import Gitlab, GitlabAuthenticationError, GitlabGetError import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA @@ -141,12 +142,10 @@ class GitLabData: def __init__(self, gitlab_id, priv_token, interval, url): """Fetch data from GitLab API for most recent CI job.""" - import gitlab self._gitlab_id = gitlab_id - self._gitlab = gitlab.Gitlab(url, private_token=priv_token, per_page=1) + self._gitlab = Gitlab(url, private_token=priv_token, per_page=1) self._gitlab.auth() - self._gitlab_exceptions = gitlab.exceptions self.update = Throttle(interval)(self._update) self.available = False @@ -174,9 +173,9 @@ class GitLabData: self.build_id = _last_job.attributes.get("id") self.branch = _last_job.attributes.get("ref") self.available = True - except self._gitlab_exceptions.GitlabAuthenticationError as erra: + except GitlabAuthenticationError as erra: _LOGGER.error("Authentication Error: %s", erra) self.available = False - except self._gitlab_exceptions.GitlabGetError as errg: + except GitlabGetError as errg: _LOGGER.error("Project Not Found: %s", errg) self.available = False