This repository was archived by the owner on Aug 27, 2021. It is now read-only.
Sourcery Starbot ⭐ refactored PTST/O365-HomeAssistant#77
Open
SourceryAI wants to merge 1 commit intoPTST:masterfrom
Open
Sourcery Starbot ⭐ refactored PTST/O365-HomeAssistant#77SourceryAI wants to merge 1 commit intoPTST:masterfrom
SourceryAI wants to merge 1 commit intoPTST:masterfrom
Conversation
SourceryAI
commented
Jun 23, 2020
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: |
Author
There was a problem hiding this comment.
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) |
Author
There was a problem hiding this comment.
Function async_get_service refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
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) |
Author
There was a problem hiding this comment.
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)
Comment on lines
-194
to
+196
| calendar_info = CALENDAR_DEVICE_SCHEMA( | ||
| return CALENDAR_DEVICE_SCHEMA( |
Author
There was a problem hiding this comment.
Function get_calendar_info refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: