Skip to content

Commit

Permalink
improve conformation to PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertD502 authored Oct 4, 2022
1 parent 7c51e05 commit 2f7aa9f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions custom_components/flair/util.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
""" Utilities for Flair Integration """
"""Utilities for Flair Integration"""
from __future__ import annotations



import async_timeout

from flairaio import FlairClient
from flairaio.exceptions import FlairAuthError
from flairaio.model import Structure, User
Expand All @@ -13,8 +12,10 @@

from .const import LOGGER, FLAIR_ERRORS, TIMEOUT


async def async_validate_api(hass: HomeAssistant, client_id: str, client_secret: str) -> bool:
""" Get data from API. """
"""Get data from API."""

client = FlairClient(
client_id,
client_secret,
Expand All @@ -28,13 +29,14 @@ async def async_validate_api(hass: HomeAssistant, client_id: str, client_secret:
structures_query = await client.get_structures()
except FlairAuthError as err:
LOGGER.error(f'Could not authenticate on Flair servers: {err}')
raise FlairAuthError from err
raise FlairAuthError(err)
except FLAIR_ERRORS as err:
LOGGER.error(f'Failed to get information from Flair servers: {err}')
raise ConnectionError from err

users: dict[str, User] = users_query.users
structures: dict[str, Structure] = structures_query.structures

if not users:
LOGGER.error("Could not retrieve any users from Flair servers")
raise NoUserError
Expand All @@ -47,5 +49,6 @@ async def async_validate_api(hass: HomeAssistant, client_id: str, client_secret:
class NoUserError(Exception):
""" No User from Flair API. """


class NoStructuresError(Exception):
""" No Litter Boxes from PurrSong API. """

0 comments on commit 2f7aa9f

Please sign in to comment.