Skip to content

Commit

Permalink
More typehints
Browse files Browse the repository at this point in the history
  • Loading branch information
Siecje committed Feb 15, 2024
1 parent 48b1963 commit 2c90d32
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bleak/backends/characteristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_descriptor(
raise NotImplementedError()

@abc.abstractmethod
def add_descriptor(self, descriptor: BleakGATTDescriptor):
def add_descriptor(self, descriptor: BleakGATTDescriptor) -> None:
"""Add a :py:class:`~BleakGATTDescriptor` to the characteristic.
Should not be used by end user, but rather by `bleak` itself.
Expand Down
4 changes: 2 additions & 2 deletions bleak/backends/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def register_detection_callback(

if inspect.iscoroutinefunction(callback):

def detection_callback(s, d):
def detection_callback(s: BLEDevice, d: AdvertisementData) -> None:
task = asyncio.create_task(callback(s, d))
_background_tasks.add(task)
task.add_done_callback(_background_tasks.discard)
Expand All @@ -192,7 +192,7 @@ def detection_callback(s, d):

self._ad_callbacks[token] = detection_callback

def remove():
def remove() -> None:
self._ad_callbacks.pop(token, None)

return remove
Expand Down
14 changes: 7 additions & 7 deletions bleak/backends/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
class BleakGATTService(abc.ABC):
"""Interface for the Bleak representation of a GATT Service."""

def __init__(self, obj):
def __init__(self, obj) -> None:
self.obj = obj

def __str__(self):
def __str__(self) -> str:
return f"{self.uuid} (Handle: {self.handle}): {self.description}"

@property
Expand All @@ -51,7 +51,7 @@ def characteristics(self) -> List[BleakGATTCharacteristic]:
raise NotImplementedError()

@abc.abstractmethod
def add_characteristic(self, characteristic: BleakGATTCharacteristic):
def add_characteristic(self, characteristic: BleakGATTCharacteristic) -> None:
"""Add a :py:class:`~BleakGATTCharacteristic` to the service.
Should not be used by end user, but rather by `bleak` itself.
Expand Down Expand Up @@ -81,7 +81,7 @@ def get_characteristic(
class BleakGATTServiceCollection:
"""Simple data container for storing the peripheral's service complement."""

def __init__(self):
def __init__(self) -> None:
self.__services = {}
self.__characteristics = {}
self.__descriptors = {}
Expand Down Expand Up @@ -117,7 +117,7 @@ def descriptors(self) -> Dict[int, BleakGATTDescriptor]:
"""Returns a dictionary of integer handles mapping to BleakGATTDescriptor"""
return self.__descriptors

def add_service(self, service: BleakGATTService):
def add_service(self, service: BleakGATTService) -> None:
"""Add a :py:class:`~BleakGATTService` to the service collection.
Should not be used by end user, but rather by `bleak` itself.
Expand Down Expand Up @@ -153,7 +153,7 @@ def get_service(

return x[0] if x else None

def add_characteristic(self, characteristic: BleakGATTCharacteristic):
def add_characteristic(self, characteristic: BleakGATTCharacteristic) -> None:
"""Add a :py:class:`~BleakGATTCharacteristic` to the service collection.
Should not be used by end user, but rather by `bleak` itself.
Expand Down Expand Up @@ -191,7 +191,7 @@ def get_characteristic(

return x[0] if x else None

def add_descriptor(self, descriptor: BleakGATTDescriptor):
def add_descriptor(self, descriptor: BleakGATTDescriptor) -> None:
"""Add a :py:class:`~BleakGATTDescriptor` to the service collection.
Should not be used by end user, but rather by `bleak` itself.
Expand Down
2 changes: 1 addition & 1 deletion bleak/uuids.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@
}


def uuidstr_to_str(uuid_):
def uuidstr_to_str(uuid_: str) -> str:
uuid_ = uuid_.lower()
s = uuid128_dict.get(uuid_)
if s:
Expand Down

0 comments on commit 2c90d32

Please sign in to comment.