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

BleakScanner.find_device_by_filter() signature changed in v0.18.0 #1028

Closed
jeffsf opened this issue Sep 24, 2022 · 2 comments · Fixed by #1030
Closed

BleakScanner.find_device_by_filter() signature changed in v0.18.0 #1028

jeffsf opened this issue Sep 24, 2022 · 2 comments · Fixed by #1030
Labels
bug Something isn't working

Comments

@jeffsf
Copy link

jeffsf commented Sep 24, 2022

Between v0.17.0 and v0.18.0, a named parameter changed from filterfunc to filter_func

Calls to find_device_by_filter that identify the parameter by name will fail in one version.

Workarounds:

  • Detect the version and branch between two call signatures
  • Convert to a positional argument list
  • Require v0.18.0 or later and hope that the user is using pip or equivalent

In v0.17.0, in bleak/backends/scanner.py

    234     @classmethod
    235     async def find_device_by_filter(
    236         cls, filterfunc: AdvertisementDataFilter, timeout: float = 10.0, **kwargs
    237     ) -> Optional[BLEDevice]:

In v0.18.0, in bleak/__init__.py

    227     @classmethod
    228     async def find_device_by_filter(
    229         cls, filter_func: AdvertisementDataFilter, timeout: float = 10.0, **kwargs
    230     ) -> Optional[BLEDevice]:
@dlech dlech added the bug Something isn't working label Sep 24, 2022
@dlech
Copy link
Collaborator

dlech commented Sep 24, 2022

Bah, I should know better than to have changed that.

@jeffsf
Copy link
Author

jeffsf commented Sep 24, 2022

It also looks like there is an inconsistency between device_or_address in __init__.py and address_or_ble_device in the backends.

    301     def __init__(
    302         self,
    303         device_or_address: Union[BLEDevice, str],
    304         disconnected_callback: Optional[Callable[[BleakClient], None]] = None,
    305         *,
    306         timeout: float = 10.0,
    307         winrt: WinRTClientArgs = {},
    308         backend: Optional[Type[BaseBleakClient]] = None,
    309         **kwargs,
    310     ):
bleak/backends/bluezdbus/client.py:    def __init__(self, address_or_ble_device: Union[BLEDevice, str], **kwargs):
bleak/backends/client.py:    def __init__(self, address_or_ble_device: Union[BLEDevice, str], **kwargs):
bleak/backends/corebluetooth/client.py:    def __init__(self, address_or_ble_device: Union[BLEDevice, str], **kwargs):
bleak/backends/p4android/client.py:    def __init__(self, address_or_ble_device: Union[BLEDevice, str], **kwargs):
bleak/backends/winrt/client.py:        address_or_ble_device: Union[BLEDevice, str],

jeffsf added a commit to jeffsf/pyDE1 that referenced this issue Sep 25, 2022
Starting with bleak v0.18.0, the method signature changed
for BleakScanner.find_device_by_filter()
hbldh/bleak#1028

There are other changes as well that need to be accommodated

BLEAK_AFTER_0_17 is True with v0.18.0 and later
@dlech dlech mentioned this issue Sep 25, 2022
@dlech dlech linked a pull request Sep 25, 2022 that will close this issue
@dlech dlech closed this as completed in e0cb89f Sep 25, 2022
jeffsf added a commit to jeffsf/pyDE1 that referenced this issue Oct 2, 2022
Starting with bleak v0.18.0, the method signature changed
for BleakScanner.find_device_by_filter()
hbldh/bleak#1028

There are other changes as well that need to be accommodated

BLEAK_AFTER_0_17 is True with v0.18.0 and later
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants