-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix: typing for generic BleakClient classes and the retry_bluetooth_connection_error decorator #86
fix: typing for generic BleakClient classes and the retry_bluetooth_connection_error decorator #86
Conversation
Using a bound TypeVar we can ensure that any client class we are dealing with is either BleakClient or a descendant of it and that type then stays consistent throughout the lifecycle. Signed-off-by: Felix Kaechele <felix@kaechele.ca>
Use TypeVar together with ParamVar to drop the use of the unsafe cast operation. Signed-off-by: Felix Kaechele <felix@kaechele.ca>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #86 +/- ##
=======================================
Coverage ? 78.15%
=======================================
Files ? 4
Lines ? 412
Branches ? 93
=======================================
Hits ? 322
Misses ? 61
Partials ? 29
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Python 3.9 test fails due to missing ParamSpec support. Can we drop Python 3.9 now that Home Assistant only supports 3.10 and 3.11 or should we postpone that change until 3.9 support can be dropped? Lint stage fails due to antiquated pre-commit-hooks that are now broken. See my other PR. |
Please drop python 3.9 in another PR. It should be marked as a BREAKING CHANGE |
Will do. Preparing that PR now. |
Will take a look tomorrow if Wi-Fi works inflight |
Thanks! Safe travels! |
async def _async_wrap_bluetooth_connection_error_retry( | ||
*args: Any, **kwargs: Any | ||
) -> Any: | ||
async def _async_wrap_bluetooth_connection_error_retry( # type: ignore[return] |
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.
The mypy ignore here is needed because mypy expects the function to also return outside of the for
loop. But there isn't anything sensible we could return there.
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 @kaechele
I’ll fix the lint issues after I make my connection 🛬 |
3.0.0 published. If you plan on bumping HA, I can take a look when I land ~9hrs if I'm not too tired. |
No rush. My integration I'm working on is still a while out. |
This should be the correct way of dealing with both of these types and mypy.