-
Notifications
You must be signed in to change notification settings - Fork 13
Sourcery Starbot ⭐ refactored PTST/O365-HomeAssistant #77
base: master
Are you sure you want to change the base?
Conversation
| 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: |
There was a problem hiding this comment.
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 using De Morgan identities (
de-morgan)
| return | ||
| email_service = O365EmailService(account) | ||
| return email_service | ||
| return O365EmailService(account) |
There was a problem hiding this comment.
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 immediately returned (
inline-immediately-returned-variable)
| 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) |
There was a problem hiding this comment.
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 (
comprehension-to-generator) - Simplify logical expression using De Morgan identities (
de-morgan)
| calendar_info = CALENDAR_DEVICE_SCHEMA( | ||
| return CALENDAR_DEVICE_SCHEMA( |
There was a problem hiding this comment.
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 immediately returned (
inline-immediately-returned-variable)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: