-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use decorator for AsusWrt api calls #103690
Conversation
Hey there @kennedyshead, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
280f965
to
ad2851a
Compare
@@ -52,6 +54,28 @@ def _get_dict(keys: list, values: list) -> dict[str, Any]: | |||
return dict(zip(keys, values)) | |||
|
|||
|
|||
def handle_errors_and_zip(exceptions: Any, keys: list | None) -> Callable: |
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.
Can you please improve the typing by setting the arguments and return value of the callable
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.
Improved. Let me know if it looks good.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
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.
Please add tests for the new decorator
"""Create a dict from a list of keys and values.""" | ||
return dict(zip(keys, values)) | ||
def handle_errors_and_zip( | ||
exceptions: Union[type[Exception], tuple[type[Exception], ...]], |
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.
exceptions: Union[type[Exception], tuple[type[Exception], ...]], | |
exceptions: type[Exception] | tuple[type[Exception], ...], |
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.
I improved a little bit more typing defining 2 type alias,
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.
Thanks @ollo69 👍
Proposed change
Use a decorator to avoid repetition of same code in the API calls inside
bridge.py
module.Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: