This repository was archived by the owner on Aug 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Sourcery refactored master branch #76
Open
sourcery-ai
wants to merge
1
commit into
master
Choose a base branch
from
sourcery/master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,8 +25,7 @@ async def async_get_service(hass, config, discovery_info=None): | |
| is_authenticated = account.is_authenticated | ||
| if not is_authenticated: | ||
| return | ||
| email_service = O365EmailService(account) | ||
| return email_service | ||
| return O365EmailService(account) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function async_get_service refactored with the following changes:
|
||
|
|
||
|
|
||
| class O365EmailService(BaseNotificationService): | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,14 +37,16 @@ def clean_html(html): | |
|
|
||
| def validate_permissions(token_path=DEFAULT_CACHE_PATH, token_filename="o365.token"): | ||
| full_token_path = os.path.join(token_path, token_filename) | ||
| 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) | ||
|
Comment on lines
-40
to
+49
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function validate_permissions refactored with the following changes:
|
||
| if not all_permissions_granted: | ||
| _LOGGER.warning(f"All permissions granted: {all_permissions_granted}") | ||
| return all_permissions_granted | ||
|
|
@@ -191,7 +193,7 @@ def load_calendars(path): | |
|
|
||
| def get_calendar_info(hass, calendar, track_new_devices): | ||
| """Convert data from O365 into DEVICE_SCHEMA.""" | ||
| calendar_info = CALENDAR_DEVICE_SCHEMA( | ||
| return CALENDAR_DEVICE_SCHEMA( | ||
|
Comment on lines
-194
to
+196
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function get_calendar_info refactored with the following changes:
|
||
| { | ||
| CONF_CAL_ID: calendar.calendar_id, | ||
| CONF_ENTITIES: [ | ||
|
|
@@ -203,7 +205,6 @@ def get_calendar_info(hass, calendar, track_new_devices): | |
| ], | ||
| } | ||
| ) | ||
| return calendar_info | ||
|
|
||
|
|
||
| def update_calendar_file(path, calendar, hass, track_new_devices): | ||
|
|
||
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.
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: