Skip to content
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

Concrete top level classes #982

Merged
merged 4 commits into from
Sep 21, 2022
Merged

Concrete top level classes #982

merged 4 commits into from
Sep 21, 2022

Conversation

dlech
Copy link
Collaborator

@dlech dlech commented Sep 5, 2022

This is a partial alternative to some of the code changes in #904. It implements the suggestion of creating new BleakScanner and BleakClient objects. This solves some of the documentation complications compared to the approach in #904 of using multiple inheritance. Also it will allow us to refactor some duplicated code between the backends in the future, like checking if a device is still connected and wrapping coroutine callbacks.

It is not a complete alternative to #904 as there are some really nice documentation improvements there that I think we should still pick up. And there are some other classes that are not backend-specific that could be moved out of the backends module, but they can be handled one at a time and at a later date.

cc: @jackjansen

Fixes: #582.

bleak/__init__.py Show resolved Hide resolved
bleak/__init__.py Show resolved Hide resolved
bleak/__init__.py Outdated Show resolved Hide resolved
@dlech dlech force-pushed the concrete-top-level-classes branch 3 times, most recently from a193c4f to c5191b7 Compare September 21, 2022 21:48
This allows us to put all of the documentation, including platform-
specific quirks, for BleakScanner and BleakClient in one place. Docs
for these classes are move to new sub-pages of the API docs page and
the backend docs are moved to the backend pages of the docs.

It will also allow us to eventually eliminate quite a bit of duplicated
code from the backends by moving it to these shared classes.

Several methods that provided duplicate functionality have been
deprecated (previously they were required because of backend
implementation details but can now be safely removed from the
top-level classes).
Much of the information on this page is outdated. The information that
is still relevant is now covered on the new dedicated BleakScanner class
page.
This can be useful for custom backends and testing.
@dlech dlech force-pushed the concrete-top-level-classes branch from c5191b7 to e759b45 Compare September 21, 2022 21:48
Since we were importing `bleak` in conf.py, it required some runtime
dependencies to be installed. We can avoid this by just reading the
version from the pyproject.toml file instead.
@dlech dlech merged commit d01fa05 into develop Sep 21, 2022
@dlech dlech deleted the concrete-top-level-classes branch September 21, 2022 22:11
def __init__(
self,
device_or_address: Union[BLEDevice, str],
disconnected_callback: Optional[Callable[[BleakClient], None]] = None,
Copy link
Contributor

@bdraco bdraco Sep 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this keyword arg snuck in before the *

pylint was complaining when I was doing testing keyword-arg-before-vararg

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is intentional, the arg is now positional or keyword

@dlech dlech mentioned this pull request Sep 22, 2022
dlech added a commit that referenced this pull request Sep 23, 2022
This was missed in #982 since BaseBleakClient didn't have an abstract
property for this.

This adds the base abstract property to the backends, fixes the missing
property in BleakClient client and adds it to the documentation.
dlech added a commit that referenced this pull request Sep 23, 2022
This was missed in #982 since BaseBleakClient didn't have an abstract
property for this.

This adds the base abstract property to the backends, fixes the missing
property in BleakClient client and adds it to the documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Want to use BleakClient within bleak package
3 participants