diff --git a/bleak/backends/characteristic.py b/bleak/backends/characteristic.py index c73d58b1..b6fb2594 100644 --- a/bleak/backends/characteristic.py +++ b/bleak/backends/characteristic.py @@ -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. diff --git a/bleak/backends/scanner.py b/bleak/backends/scanner.py index 60396fa7..591cd152 100644 --- a/bleak/backends/scanner.py +++ b/bleak/backends/scanner.py @@ -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) @@ -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 diff --git a/bleak/backends/service.py b/bleak/backends/service.py index 305e8bd2..2d587c58 100644 --- a/bleak/backends/service.py +++ b/bleak/backends/service.py @@ -7,7 +7,7 @@ """ import abc import logging -from typing import Dict, Iterator, List, Optional, Union +from typing import Any, Dict, Iterator, List, Optional, Union from uuid import UUID from ..exc import BleakError @@ -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: Any) -> None: self.obj = obj - def __str__(self): + def __str__(self) -> str: return f"{self.uuid} (Handle: {self.handle}): {self.description}" @property @@ -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. @@ -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 = {} @@ -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. @@ -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. @@ -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. diff --git a/bleak/uuids.py b/bleak/uuids.py index 0b6a17d6..61338158 100644 --- a/bleak/uuids.py +++ b/bleak/uuids.py @@ -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: