Skip to content
This repository was archived by the owner on Aug 27, 2021. It is now read-only.

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jun 23, 2020

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines -43 to +57
if not alt_config:
if alt_config:
callback_url = AUTH_CALLBACK_PATH_ALT

else:
try:
callback_url = f"{get_url(hass)}{AUTH_CALLBACK_PATH}"
except NameError:
callback_url = f"{hass.config.api.base_url}{AUTH_CALLBACK_PATH}"
else:
callback_url = AUTH_CALLBACK_PATH_ALT

account = Account(credentials, token_backend=TOKEN_BACKEND)
is_authenticated = account.is_authenticated
permissions = validate_permissions()
if not is_authenticated or not permissions:
if is_authenticated and permissions:
do_setup(hass, conf, account)

else:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function setup refactored with the following changes:

  • Simplify logical expression

return
email_service = O365EmailService(account)
return email_service
return O365EmailService(account)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function async_get_service refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -40 to +49
if not os.path.exists(full_token_path) or not os.path.isfile(full_token_path):
if not (
os.path.exists(full_token_path) and os.path.isfile(full_token_path)
):
_LOGGER.warning(f"Could not loacte token at {full_token_path}")
return False
with open(full_token_path, "r", encoding="UTF-8") as fh:
raw = fh.read()
permissions = json.loads(raw)["scope"]
scope = [x for x in MINIMUM_REQUIRED_SCOPES]
all_permissions_granted = all([x in permissions for x in scope])
all_permissions_granted = all(x in permissions for x in scope)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function validate_permissions refactored with the following changes:

  • Replace unneeded comprehension with generator
  • Simplify logical expression

Comment on lines -194 to +196
calendar_info = CALENDAR_DEVICE_SCHEMA(
return CALENDAR_DEVICE_SCHEMA(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_calendar_info refactored with the following changes:

  • Inline variable that is only used once

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant