Skip to content

Commit

Permalink
Sourcery code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerSelwyn committed Mar 8, 2022
1 parent adbe61d commit 3983c3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 31 deletions.
4 changes: 1 addition & 3 deletions custom_components/o365/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ async def get(self, request):

def alt_callback(self, data):
"""Receive authorization token."""
url = data.get("token")
if not url:
url = [v for k, v in data.items()][0]
url = data.get("token") or [v for k, v in data.items()][0]

result = self.account.con.request_token(
url, state=self.state, redirect_uri=AUTH_CALLBACK_PATH_ALT
Expand Down
40 changes: 12 additions & 28 deletions custom_components/o365/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,19 @@
from bs4 import BeautifulSoup
from homeassistant.util import dt
from O365.calendar import Attendee # pylint: disable=no-name-in-module)
from O365.calendar import EventSensitivity # pylint: disable=no-name-in-module)
from O365.calendar import \
EventSensitivity # pylint: disable=no-name-in-module)
from voluptuous.error import Error as VoluptuousError

from .const import (
CALENDAR_DEVICE_SCHEMA,
CONF_CAL_ID,
CONF_DEVICE_ID,
CONF_EMAIL_SENSORS,
CONF_ENABLE_UPDATE,
CONF_ENTITIES,
CONF_NAME,
CONF_QUERY_SENSORS,
CONF_STATUS_SENSORS,
CONF_TRACK,
DATETIME_FORMAT,
DEFAULT_CACHE_PATH,
PERM_CALENDARS_READ,
PERM_CALENDARS_READWRITE,
PERM_MAIL_READ,
PERM_MAIL_SEND,
PERM_MINIMUM_CALENDAR,
PERM_MINIMUM_MAIL,
PERM_MINIMUM_PRESENCE,
PERM_MINIMUM_USER,
PERM_OFFLINE_ACCESS,
PERM_PRESENCE_READ,
PERM_USER_READ,
TOKEN_FILENAME,
)
from .const import (CALENDAR_DEVICE_SCHEMA, CONF_CAL_ID, CONF_DEVICE_ID,
CONF_EMAIL_SENSORS, CONF_ENABLE_UPDATE, CONF_ENTITIES,
CONF_NAME, CONF_QUERY_SENSORS, CONF_STATUS_SENSORS,
CONF_TRACK, DATETIME_FORMAT, DEFAULT_CACHE_PATH,
PERM_CALENDARS_READ, PERM_CALENDARS_READWRITE,
PERM_MAIL_READ, PERM_MAIL_SEND, PERM_MINIMUM_CALENDAR,
PERM_MINIMUM_MAIL, PERM_MINIMUM_PRESENCE,
PERM_MINIMUM_USER, PERM_OFFLINE_ACCESS, PERM_PRESENCE_READ,
PERM_USER_READ, TOKEN_FILENAME)

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -137,7 +121,7 @@ def get_ha_filepath(hass, filepath):

if not os.path.isfile(_filepath):
if not os.path.isfile(filepath):
raise ValueError("Could not access file " + filepath + " at " + _filepath)
raise ValueError(f"Could not access file {filepath} at {_filepath}")
return filepath
return _filepath

Expand Down

0 comments on commit 3983c3a

Please sign in to comment.