Skip to content

Commit

Permalink
Fix annotation and usage of get_rfcomm_channel
Browse files Browse the repository at this point in the history
The expected type is actually int and we have to make sure that it is not None.
  • Loading branch information
cschramm authored and infirit committed Nov 3, 2019
1 parent ea61ce3 commit 44df48a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion blueman/services/meta/SerialService.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def connect(
reply_handler: Optional[Callable[[str], None]] = None,
error_handler: Optional[Callable[[RFCOMMError], None]] = None
) -> bool:
channel = get_rfcomm_channel(self.short_uuid, self.device['Address'])
# We expect this service to have a reserved UUID
uuid = self.short_uuid
assert uuid
channel = get_rfcomm_channel(uuid, self.device['Address'])
if channel is None or channel == 0:
error = RFCOMMError("Failed to get rfcomm channel")
if error_handler:
Expand Down
2 changes: 1 addition & 1 deletion stubs/_blueman.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ def create_rfcomm_device(local_address: str, remote_address: str, channel: int)
def destroy_bridge(name: str = "pan1") -> None: ...
def device_info(hci_name: str = "hci0") -> _HciInfo: ...
def page_timeout(hci_name: str = "hci0") -> float: ...
def get_rfcomm_channel(uuid: str, bdaddr: str) -> Optional[int]: ...
def get_rfcomm_channel(uuid: int, bdaddr: str) -> Optional[int]: ...
def release_rfcomm_device(id: int) -> int: ...
def rfcomm_list() -> List[_RfcommDev]: ...

0 comments on commit 44df48a

Please sign in to comment.