-
Notifications
You must be signed in to change notification settings - Fork 13
Sourcery refactored master branch #76
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
| 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 only used once
| 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
- Simplify logical expression
| 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 only used once
Branch
masterrefactored 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
masterbranch, then run: