-
Notifications
You must be signed in to change notification settings - Fork 295
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
Improved type annotations #822
Comments
Bleak should already have (mostly?) complete type hints - at least for the public APIs. Happy to take a PR to fix mypy errors. It could be better if we did something like #582 though. |
I've put about 1.5 hours into an initial investigation. For hacks to make mypy "pass" (but still be useful) I would estimate 40 - 80 hours of work. Per backend it varies. The android implementation is particularly worrisome and I'm certain that the static analysis is revealing true runtime bugs. Generally, the architecture itself, due to supporting multiple backends, is not very strongly typed. For example, while interfaces are defined, they are not generic and the implementations tend to "add what they need". What I'd recommend is splitting up the approach:
Total maybe 120 hours for one person. For the project, more, managing reviews and test coverage of 30-40 PRs. For reference, here's the initial mypy error list as of posting:
|
Then again, there is some low-hanging fruit. For example, users are frequently allowed to use int, str, or uuid to specify BLE resources. This is counterproductive - the user should be forced to put their int, str, or uuid into the correct type. This converts a runtime error into a "squiggle" in the code editor, all while relieving pressure on the documentation. That said, it must be approached without changing the existing API. Maybe not so easy. |
bluetoothctl -v
) in case of Linux: not relevantDescription
At PyCon 2022, we're sprinting to improve type annotations in the adafruit circuitpython libraries. bleak is one of the foundational libraries in the adafruit bluetooth stack, and so we can't quite get complete typing without bleak also having complete typing (or alternatively, stubs).
Is there interest in improved typing? We could produce a PR, but I wanted to check if that would be likely to be accepted first!
What I Did
Found 85 errors in 22 files (let me know if you'd like the full output pasted here)
The text was updated successfully, but these errors were encountered: