Open davclark opened 2 years ago
Bleak should already have (mostly?) complete type hints - at least for the public APIs. Happy to take a PR to fix mypy errors.
It could be better if we did something like #582 though.
I've put about 1.5 hours into an initial investigation.
For hacks to make mypy "pass" (but still be useful) I would estimate 40 - 80 hours of work.
Per backend it varies. The android implementation is particularly worrisome and I'm certain that the static analysis is revealing true runtime bugs.
Generally, the architecture itself, due to supporting multiple backends, is not very strongly typed. For example, while interfaces are defined, they are not generic and the implementations tend to "add what they need".
What I'd recommend is splitting up the approach:
Total maybe 120 hours for one person. For the project, more, managing reviews and test coverage of 30-40 PRs.
For reference, here's the initial mypy error list as of posting:
typings/CoreBluetooth/__init__.pyi:3: error: Skipping analyzing ".libdispatch": module is installed, but missing library stubs or py.typed marker [import-untyped]
typings/CoreBluetooth/__init__.pyi:4: error: Skipping analyzing ".Foundation": module is installed, but missing library stubs or py.typed marker [import-untyped]
typings/CoreBluetooth/__init__.pyi:55: error: Name "registerForConnectionEventsWithOptions_" already defined on line 52 [no-redef]
bleak/backends/p4android/recipes/bleak/fix_setup.py:1: error: Skipping analyzing "setuptools": module is installed, but missing library stubs or py.typed marker [import-untyped]
bleak/backends/p4android/recipes/bleak/__init__.py:3: error: Cannot find implementation or library stub for module named "pythonforandroid.recipe" [import-not-found]
bleak/backends/p4android/recipes/bleak/__init__.py:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
bleak/backends/p4android/recipes/bleak/__init__.py:4: error: Cannot find implementation or library stub for module named "pythonforandroid.toolchain" [import-not-found]
bleak/backends/p4android/recipes/bleak/__init__.py:5: error: Cannot find implementation or library stub for module named "sh" [import-not-found]
typings/objc/__init__.py:8: error: Missing return statement [empty-body]
typings/objc/__init__.py:12: error: Missing return statement [empty-body]
bleak/backends/corebluetooth/utils.py:40: error: "NSData" has no attribute "initWithBytes_length_" [attr-defined]
bleak/backends/corebluetooth/__init__.py:11: error: Module has no attribute "options" [attr-defined]
bleak/backends/winrt/descriptor.py:7: error: Cannot find implementation or library stub for module named "bleak_winrt.windows.devices.bluetooth.genericattributeprofile" [import-not-found]
bleak/backends/bluezdbus/utils.py:22: error: Argument 1 to "BleakDBusError" has incompatible type "str | ErrorType | None"; expected "str" [arg-type]
bleak/backends/service.py:98: error: Argument 1 to "get_descriptor" of "BleakGATTServiceCollection" has incompatible type "str | int | UUID"; expected "int" [arg-type]
bleak/backends/winrt/characteristic.py:12: error: Cannot find implementation or library stub for module named "bleak_winrt.windows.devices.bluetooth.genericattributeprofile" [import-not-found]
bleak/backends/winrt/characteristic.py:73: error: Need type annotation for "__descriptors" (hint: "__descriptors: List[<type>] = ...") [var-annotated]
bleak/backends/corebluetooth/characteristic.py:99: error: Incompatible return value type (got "list[BleakGATTDescriptorCoreBluetooth]", expected "list[BleakGATTDescriptor]") [return-value]
bleak/backends/corebluetooth/characteristic.py:99: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
bleak/backends/corebluetooth/characteristic.py:99: note: Consider using "Sequence" instead, which is covariant
bleak/backends/corebluetooth/characteristic.py:118: error: Argument 1 to "append" of "list" has incompatible type "BleakGATTDescriptor"; expected "BleakGATTDescriptorCoreBluetooth" [arg-type]
bleak/backends/bluezdbus/characteristic.py:44: error: Need type annotation for "__descriptors" (hint: "__descriptors: List[<type>] = ...") [var-annotated]
docs/conf.py:217: error: Need type annotation for "latex_elements" (hint: "latex_elements: Dict[<type>, <type>] = ...") [var-annotated]
bleak/backends/winrt/service.py:9: error: Cannot find implementation or library stub for module named "bleak_winrt.windows.devices.bluetooth.genericattributeprofile" [import-not-found]
bleak/backends/winrt/service.py:22: error: Need type annotation for "__characteristics" (hint: "__characteristics: List[<type>] = ...") [var-annotated]
bleak/backends/winrt/service.py:33: error: Signature of "characteristics" incompatible with supertype "BleakGATTService" [override]
bleak/backends/winrt/service.py:33: note: Superclass:
bleak/backends/winrt/service.py:33: note: list[BleakGATTCharacteristic]
bleak/backends/winrt/service.py:33: note: Subclass:
bleak/backends/winrt/service.py:33: note: list[BleakGATTCharacteristicWinRT]
bleak/backends/winrt/service.py:37: error: Argument 1 of "add_characteristic" is incompatible with supertype "BleakGATTService"; supertype defines the argument type as "BleakGATTCharacteristic" [override]
bleak/backends/winrt/service.py:37: note: This violates the Liskov substitution principle
bleak/backends/winrt/service.py:37: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/corebluetooth/service.py:31: error: Signature of "characteristics" incompatible with supertype "BleakGATTService" [override]
bleak/backends/corebluetooth/service.py:31: note: Superclass:
bleak/backends/corebluetooth/service.py:31: note: list[BleakGATTCharacteristic]
bleak/backends/corebluetooth/service.py:31: note: Subclass:
bleak/backends/corebluetooth/service.py:31: note: list[BleakGATTCharacteristicCoreBluetooth]
bleak/backends/corebluetooth/service.py:35: error: Argument 1 of "add_characteristic" is incompatible with supertype "BleakGATTService"; supertype defines the argument type as "BleakGATTCharacteristic" [override]
bleak/backends/corebluetooth/service.py:35: note: This violates the Liskov substitution principle
bleak/backends/corebluetooth/service.py:35: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/bluezdbus/service.py:28: error: Signature of "characteristics" incompatible with supertype "BleakGATTService" [override]
bleak/backends/bluezdbus/service.py:28: note: Superclass:
bleak/backends/bluezdbus/service.py:28: note: list[BleakGATTCharacteristic]
bleak/backends/bluezdbus/service.py:28: note: Subclass:
bleak/backends/bluezdbus/service.py:28: note: list[BleakGATTCharacteristicBlueZDBus]
bleak/backends/bluezdbus/service.py:32: error: Argument 1 of "add_characteristic" is incompatible with supertype "BleakGATTService"; supertype defines the argument type as "BleakGATTCharacteristic" [override]
bleak/backends/bluezdbus/service.py:32: note: This violates the Liskov substitution principle
bleak/backends/bluezdbus/service.py:32: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/p4android/utils.py:7: error: Cannot find implementation or library stub for module named "jnius" [import-not-found]
bleak/backends/p4android/utils.py:19: error: Need type annotation for "states" (hint: "states: Dict[<type>, <type>] = ...") [var-annotated]
bleak/backends/p4android/utils.py:20: error: Need type annotation for "futures" (hint: "futures: Dict[<type>, <type>] = ...") [var-annotated]
bleak/backends/corebluetooth/CentralManagerDelegate.py:48: error: Module has no attribute "protocolNamed" [attr-defined]
bleak/backends/corebluetooth/CentralManagerDelegate.py:61: error: Incompatible types in assignment (expression has type "CentralManagerDelegate | None", variable has type "CentralManagerDelegate") [assignment]
bleak/backends/corebluetooth/CentralManagerDelegate.py:118: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/CentralManagerDelegate.py:142: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/CentralManagerDelegate.py:156: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/CentralManagerDelegate.py:189: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/CentralManagerDelegate.py:200: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/CentralManagerDelegate.py:217: error: Value of type "NSDictionary" is not indexable [index]
bleak/backends/corebluetooth/CentralManagerDelegate.py:239: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/CentralManagerDelegate.py:264: error: Function "callback" could always be true in boolean context [truthy-function]
bleak/backends/corebluetooth/CentralManagerDelegate.py:265: error: Argument 2 has incompatible type "NSDictionary"; expected "dict[str, Any]" [arg-type]
bleak/backends/corebluetooth/CentralManagerDelegate.py:265: error: Argument 3 has incompatible type "NSNumber"; expected "int" [arg-type]
bleak/backends/corebluetooth/CentralManagerDelegate.py:272: error: "NSDictionary" has no attribute "keys" [attr-defined]
bleak/backends/corebluetooth/CentralManagerDelegate.py:292: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/CentralManagerDelegate.py:310: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/CentralManagerDelegate.py:338: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/bluezdbus/signals.py:80: error: Incompatible types in assignment (expression has type "None", variable has type "str") [assignment]
bleak/backends/bluezdbus/signals.py:86: error: Incompatible types in assignment (expression has type "None", variable has type "str") [assignment]
bleak/backends/bluezdbus/signals.py:92: error: Incompatible types in assignment (expression has type "None", variable has type "str") [assignment]
bleak/backends/bluezdbus/signals.py:98: error: Incompatible types in assignment (expression has type "None", variable has type "str") [assignment]
bleak/backends/bluezdbus/signals.py:104: error: Incompatible types in assignment (expression has type "None", variable has type "str") [assignment]
bleak/backends/bluezdbus/signals.py:115: error: Incompatible types in assignment (expression has type "None", variable has type "str") [assignment]
bleak/backends/bluezdbus/signals.py:121: error: Incompatible types in assignment (expression has type "None", variable has type "str") [assignment]
bleak/backends/bluezdbus/signals.py:136: error: Incompatible types in assignment (expression has type "None", variable has type "dict[str, str]") [assignment]
bleak/backends/bluezdbus/signals.py:178: error: Incompatible return value type (got "Coroutine[Any, Any, Message | None]", expected "Coroutine[Any, Any, Message]") [return-value]
bleak/backends/bluezdbus/signals.py:192: error: Incompatible return value type (got "Coroutine[Any, Any, Message | None]", expected "Coroutine[Any, Any, Message]") [return-value]
bleak/backends/bluezdbus/manager.py:178: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
bleak/backends/bluezdbus/manager.py:182: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
bleak/backends/bluezdbus/manager.py:185: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
bleak/backends/bluezdbus/manager.py:191: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
bleak/backends/bluezdbus/manager.py:193: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
bleak/backends/bluezdbus/manager.py:195: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
bleak/backends/bluezdbus/manager.py:197: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
bleak/backends/bluezdbus/manager.py:198: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
bleak/backends/bluezdbus/manager.py:199: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
bleak/backends/bluezdbus/manager.py:200: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
bleak/backends/bluezdbus/manager.py:201: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
bleak/backends/bluezdbus/manager.py:395: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/manager.py:405: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/manager.py:408: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/manager.py:416: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/manager.py:428: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/manager.py:438: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/manager.py:444: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/manager.py:454: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/manager.py:508: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/manager.py:520: error: Item "None" of "Message | Any | None" has no attribute "message_type" [union-attr]
bleak/backends/bluezdbus/manager.py:521: error: Item "None" of "Message | Any | None" has no attribute "error_name" [union-attr]
bleak/backends/bluezdbus/manager.py:527: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/manager.py:531: error: Item "None" of "MessageBus | None" has no attribute "export" [union-attr]
bleak/backends/bluezdbus/manager.py:951: error: Invalid index type "str | None" for "dict[str, dict[str, dict[str, Any]]]"; expected type "str" [index]
bleak/backends/bluezdbus/manager.py:986: error: Incompatible types in assignment (expression has type "DeviceConditionCallback", variable has type "Callable[[str], None]") [assignment]
bleak/backends/bluezdbus/manager.py:987: error: "Callable[[str], None]" has no attribute "property_name" [attr-defined]
bleak/backends/bluezdbus/manager.py:989: error: "Callable[[str], None]" has no attribute "callback" [attr-defined]
bleak/backends/client.py:136: error: Need type annotation for "f" [var-annotated]
bleak/backends/client.py:138: error: Incompatible return value type (got "Future[Any]", expected "bool") [return-value]
bleak/backends/p4android/defs.py:6: error: Cannot find implementation or library stub for module named "jnius" [import-not-found]
bleak/backends/winrt/scanner.py:16: error: Cannot find implementation or library stub for module named "bleak_winrt.windows.devices.bluetooth.advertisement" [import-not-found]
bleak/backends/winrt/scanner.py:122: error: No overload variant of "get" of "dict" matches argument types "str", "_RawAdvData" [call-overload]
bleak/backends/winrt/scanner.py:122: note: Possible overload variants:
bleak/backends/winrt/scanner.py:122: note: def get(self, int, /) -> _RawAdvData | None
bleak/backends/winrt/scanner.py:122: note: def get(self, int, _RawAdvData, /) -> _RawAdvData
bleak/backends/winrt/scanner.py:122: note: def [_T] get(self, int, _T, /) -> _RawAdvData | _T
bleak/backends/winrt/scanner.py:130: error: Invalid index type "str" for "dict[int, _RawAdvData]"; expected type "int" [index]
bleak/backends/winrt/scanner.py:195: error: Argument 2 to "create_or_update_device" of "BaseBleakScanner" has incompatible type "Any | None"; expected "str" [arg-type]
bleak/backends/winrt/scanner.py:228: error: "None" has no attribute "scanning_mode" [attr-defined]
bleak/backends/winrt/scanner.py:231: error: Incompatible types in assignment (expression has type "Event", variable has type "None") [assignment]
bleak/backends/winrt/scanner.py:233: error: "None" has no attribute "add_received" [attr-defined]
bleak/backends/winrt/scanner.py:236: error: "None" has no attribute "add_stopped" [attr-defined]
bleak/backends/winrt/scanner.py:241: error: "None" has no attribute "signal_strength_filter" [attr-defined]
bleak/backends/winrt/scanner.py:243: error: "None" has no attribute "advertisement_filter" [attr-defined]
bleak/backends/winrt/scanner.py:245: error: "None" has no attribute "start" [attr-defined]
bleak/backends/winrt/scanner.py:248: error: "None" has no attribute "stop" [attr-defined]
bleak/backends/winrt/scanner.py:250: error: "None" has no attribute "status" [attr-defined]
bleak/backends/winrt/scanner.py:251: error: "None" has no attribute "wait" [attr-defined]
bleak/backends/winrt/scanner.py:255: error: "None" has no attribute "status" [attr-defined]
bleak/backends/winrt/scanner.py:259: error: "None" has no attribute "remove_received" [attr-defined]
bleak/backends/winrt/scanner.py:260: error: "None" has no attribute "remove_stopped" [attr-defined]
bleak/backends/p4android/scanner.py:14: error: Cannot find implementation or library stub for module named "android.broadcast" [import-not-found]
bleak/backends/p4android/scanner.py:15: error: Cannot find implementation or library stub for module named "android.permissions" [import-not-found]
bleak/backends/p4android/scanner.py:16: error: Cannot find implementation or library stub for module named "jnius" [import-not-found]
bleak/backends/p4android/scanner.py:74: error: Incompatible types in assignment (expression has type "_PythonScanCallback", variable has type "None") [assignment]
bleak/backends/p4android/characteristic.py:27: error: Need type annotation for "__descriptors" (hint: "__descriptors: List[<type>] = ...") [var-annotated]
bleak/backends/p4android/characteristic.py:67: error: Argument 1 of "get_descriptor" is incompatible with supertype "BleakGATTCharacteristic"; supertype defines the argument type as "int | str | UUID" [override]
bleak/backends/p4android/characteristic.py:67: note: This violates the Liskov substitution principle
bleak/backends/p4android/characteristic.py:67: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/p4android/characteristic.py:91: error: Incompatible types in assignment (expression has type "BleakGATTDescriptor", variable has type "None") [assignment]
bleak/backends/p4android/characteristic.py:96: error: Incompatible return value type (got "None", expected "BleakGATTDescriptor") [return-value]
bleak/backends/corebluetooth/scanner.py:6: error: Module "Foundation" has no attribute "NSBundle" [attr-defined]
bleak/backends/corebluetooth/scanner.py:131: error: Item "None" of "CentralManagerDelegate | None" has no attribute "central_manager" [union-attr]
bleak/backends/corebluetooth/scanner.py:140: error: Item "None" of "CentralManagerDelegate | None" has no attribute "central_manager" [union-attr]
bleak/backends/corebluetooth/scanner.py:146: error: Item "None" of "CentralManagerDelegate | None" has no attribute "callbacks" [union-attr]
bleak/backends/corebluetooth/scanner.py:147: error: Item "None" of "CentralManagerDelegate | None" has no attribute "start_scan" [union-attr]
bleak/backends/corebluetooth/scanner.py:150: error: Item "None" of "CentralManagerDelegate | None" has no attribute "stop_scan" [union-attr]
bleak/backends/corebluetooth/scanner.py:151: error: Item "None" of "CentralManagerDelegate | None" has no attribute "callbacks" [union-attr]
bleak/backends/corebluetooth/PeripheralDelegate.py:36: error: Module has no attribute "protocolNamed" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:48: error: Incompatible types in assignment (expression has type "PeripheralDelegate | None", variable has type "PeripheralDelegate") [assignment]
bleak/backends/corebluetooth/PeripheralDelegate.py:75: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:100: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:111: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:122: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:137: error: Incompatible return value type (got "Any | None", expected "NSArray") [return-value]
bleak/backends/corebluetooth/PeripheralDelegate.py:139: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:147: error: Incompatible return value type (got "Any | None", expected "NSData") [return-value]
bleak/backends/corebluetooth/PeripheralDelegate.py:159: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:175: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:190: error: Argument 3 to "writeValue_forCharacteristic_type_" of "CBPeripheral" has incompatible type "bleak.backends.corebluetooth.PeripheralDelegate.CBCharacteristicWriteType"; expected "CoreBluetooth.CBCharacteristicWriteType" [arg-type]
bleak/backends/corebluetooth/PeripheralDelegate.py:197: error: Argument 3 to "writeValue_forCharacteristic_type_" of "CBPeripheral" has incompatible type "bleak.backends.corebluetooth.PeripheralDelegate.CBCharacteristicWriteType"; expected "CoreBluetooth.CBCharacteristicWriteType" [arg-type]
bleak/backends/corebluetooth/PeripheralDelegate.py:200: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:211: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:230: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:247: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:260: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:283: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:320: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:358: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:377: error: No overload variant of "bytearray" matches argument type "NSData" [call-overload]
bleak/backends/corebluetooth/PeripheralDelegate.py:377: note: Possible overload variants:
bleak/backends/corebluetooth/PeripheralDelegate.py:377: note: def __init__(self) -> bytearray
bleak/backends/corebluetooth/PeripheralDelegate.py:377: note: def __init__(self, Iterable[SupportsIndex] | SupportsIndex | Buffer, /) -> bytearray
bleak/backends/corebluetooth/PeripheralDelegate.py:377: note: def __init__(self, str, /, encoding: str, errors: str = ...) -> bytearray
bleak/backends/corebluetooth/PeripheralDelegate.py:402: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:438: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:471: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:505: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:542: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:562: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:572: error: Module has no attribute "python_method" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:604: error: Module has no attribute "classAddMethod" [attr-defined]
bleak/backends/corebluetooth/PeripheralDelegate.py:621: error: Module has no attribute "classAddMethod" [attr-defined]
bleak/backends/bluezdbus/scanner.py:180: error: Argument 2 to "passive_scan" of "BlueZManager" has incompatible type "list[OrPattern | tuple[int, AdvertisementDataType, bytes]] | None"; expected "list[OrPattern | tuple[int, AdvertisementDataType, bytes]]" [arg-type]
bleak/__init__.py:148: error: Too many arguments for "BaseBleakScanner" [call-arg]
bleak/__init__.py:148: error: Unexpected keyword argument "bluez" for "BaseBleakScanner" [call-arg]
bleak/backends/scanner.py:132: note: "BaseBleakScanner" defined here
bleak/__init__.py:148: error: Unexpected keyword argument "cb" for "BaseBleakScanner" [call-arg]
bleak/backends/scanner.py:132: note: "BaseBleakScanner" defined here
bleak/__init__.py:237: error: Need type annotation for "devices" [var-annotated]
bleak/__init__.py:294: error: Overloaded function implementation does not accept all possible arguments of signature 1 [misc]
bleak/__init__.py:294: error: Overloaded function implementation does not accept all possible arguments of signature 2 [misc]
bleak/__init__.py:414: error: Missing return statement [return]
bleak/__init__.py:717: error: Incompatible default for argument "response" (default has type "None", argument has type "bool") [assignment]
bleak/__init__.py:717: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
bleak/__init__.py:717: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
bleak/__init__.py:766: error: Incompatible types in assignment (expression has type "BleakGATTCharacteristic | None", variable has type "BleakGATTCharacteristic") [assignment]
bleak/__init__.py:769: error: Argument 1 to "BleakCharacteristicNotFoundError" has incompatible type "BleakGATTCharacteristic | int | str | UUID"; expected "int | str | UUID" [arg-type]
bleak/__init__.py:822: error: Argument 1 to "BleakCharacteristicNotFoundError" has incompatible type "BleakGATTCharacteristic | int | str | UUID"; expected "int | str | UUID" [arg-type]
bleak/backends/winrt/client.py:13: error: Module "ctypes" has no attribute "WinError" [attr-defined]
bleak/backends/winrt/client.py:71: error: Cannot find implementation or library stub for module named "bleak_winrt.windows.devices.bluetooth" [import-not-found]
bleak/backends/winrt/client.py:77: error: Cannot find implementation or library stub for module named "bleak_winrt.windows.devices.bluetooth.genericattributeprofile" [import-not-found]
bleak/backends/winrt/client.py:90: error: Cannot find implementation or library stub for module named "bleak_winrt.windows.devices.enumeration" [import-not-found]
bleak/backends/winrt/client.py:96: error: Cannot find implementation or library stub for module named "bleak_winrt.windows.foundation" [import-not-found]
bleak/backends/winrt/client.py:101: error: Cannot find implementation or library stub for module named "bleak_winrt.windows.storage.streams" [import-not-found]
bleak/backends/winrt/client.py:516: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_characteristic" [union-attr]
bleak/backends/winrt/client.py:517: error: Item "None" of "BleakGATTCharacteristic | Any | None" has no attribute "obj" [union-attr]
bleak/backends/winrt/client.py:562: error: Incompatible return value type (got "_DeprecatedIsConnectedReturn", expected "bool") [return-value]
bleak/backends/winrt/client.py:573: error: Incompatible default for argument "protection_level" (default has type "None", argument has type "int") [assignment]
bleak/backends/winrt/client.py:573: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
bleak/backends/winrt/client.py:573: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
bleak/backends/winrt/client.py:590: error: Item "None" of "Any | None" has no attribute "device_information" [union-attr]
bleak/backends/winrt/client.py:714: error: Item "None" of "Any | None" has no attribute "get_gatt_services_async" [union-attr]
bleak/backends/winrt/client.py:718: error: Item "None" of "Any | None" has no attribute "get_gatt_services_async" [union-attr]
bleak/backends/winrt/client.py:730: error: Item "None" of "Any | None" has no attribute "get_gatt_services_for_uuid_async" [union-attr]
bleak/backends/winrt/client.py:824: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_characteristic" [union-attr]
bleak/backends/winrt/client.py:828: error: Argument 1 to "BleakCharacteristicNotFoundError" has incompatible type "BleakGATTCharacteristic | int | str | UUID"; expected "int | str | UUID" [arg-type]
bleak/backends/winrt/client.py:865: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_descriptor" [union-attr]
bleak/backends/winrt/client.py:899: error: Argument 1 to "len" has incompatible type "Buffer"; expected "Sized" [arg-type]
bleak/backends/winrt/client.py:920: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_descriptor" [union-attr]
bleak/backends/winrt/client.py:924: error: Argument 1 to "len" has incompatible type "Buffer"; expected "Sized" [arg-type]
bleak/backends/winrt/client.py:1011: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_characteristic" [union-attr]
bleak/backends/winrt/client.py:1015: error: Argument 1 to "BleakCharacteristicNotFoundError" has incompatible type "BleakGATTCharacteristic | int | str | UUID"; expected "int | str | UUID" [arg-type]
bleak/backends/winrt/client.py:1041: error: Need type annotation for "_callbacks" (hint: "_callbacks: List[<type>] = ...") [var-annotated]
bleak/backends/winrt/client.py:1100: error: Missing return statement [return]
bleak/backends/p4android/service.py:27: error: Signature of "characteristics" incompatible with supertype "BleakGATTService" [override]
bleak/backends/p4android/service.py:27: note: Superclass:
bleak/backends/p4android/service.py:27: note: list[BleakGATTCharacteristic]
bleak/backends/p4android/service.py:27: note: Subclass:
bleak/backends/p4android/service.py:27: note: list[BleakGATTCharacteristicP4Android]
bleak/backends/p4android/service.py:31: error: Argument 1 of "add_characteristic" is incompatible with supertype "BleakGATTService"; supertype defines the argument type as "BleakGATTCharacteristic" [override]
bleak/backends/p4android/service.py:31: note: This violates the Liskov substitution principle
bleak/backends/p4android/service.py:31: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/corebluetooth/client.py:135: error: Item "None" of "CentralManagerDelegate | None" has no attribute "connect" [union-attr]
bleak/backends/corebluetooth/client.py:150: error: Item "None" of "CentralManagerDelegate | None" has no attribute "disconnect" [union-attr]
bleak/backends/corebluetooth/client.py:157: error: Incompatible return value type (got "_DeprecatedIsConnectedReturn", expected "bool") [return-value]
bleak/backends/corebluetooth/client.py:170: error: Item "None" of "CBPeripheral | None" has no attribute "maximumWriteValueLengthForType_" [union-attr]
bleak/backends/corebluetooth/client.py:170: error: Unsupported operand types for + ("None" and "int") [operator]
bleak/backends/corebluetooth/client.py:170: note: Left operand is of type "Any | None"
bleak/backends/corebluetooth/client.py:218: error: Item "None" of "PeripheralDelegate | None" has no attribute "discover_services" [union-attr]
bleak/backends/corebluetooth/client.py:225: error: Item "None" of "PeripheralDelegate | None" has no attribute "discover_characteristics" [union-attr]
bleak/backends/corebluetooth/client.py:234: error: Item "None" of "PeripheralDelegate | None" has no attribute "discover_descriptors" [union-attr]
bleak/backends/corebluetooth/client.py:239: error: Item "None" of "CBPeripheral | None" has no attribute "maximumWriteValueLengthForType_" [union-attr]
bleak/backends/corebluetooth/client.py:239: error: Argument 2 to "BleakGATTCharacteristicCoreBluetooth" has incompatible type "Any | None"; expected "int" [arg-type]
bleak/backends/corebluetooth/client.py:276: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_characteristic" [union-attr]
bleak/backends/corebluetooth/client.py:280: error: Argument 1 to "BleakCharacteristicNotFoundError" has incompatible type "BleakGATTCharacteristic | int | str | UUID"; expected "int | str | UUID" [arg-type]
bleak/backends/corebluetooth/client.py:282: error: Item "None" of "PeripheralDelegate | None" has no attribute "read_characteristic" [union-attr]
bleak/backends/corebluetooth/client.py:302: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_descriptor" [union-attr]
bleak/backends/corebluetooth/client.py:306: error: Item "None" of "PeripheralDelegate | None" has no attribute "read_descriptor" [union-attr]
bleak/backends/corebluetooth/client.py:324: error: "NSData" has no attribute "initWithBytes_length_" [attr-defined]
bleak/backends/corebluetooth/client.py:324: error: Argument 1 to "len" has incompatible type "Buffer"; expected "Sized" [arg-type]
bleak/backends/corebluetooth/client.py:325: error: Item "None" of "PeripheralDelegate | None" has no attribute "write_characteristic" [union-attr]
bleak/backends/corebluetooth/client.py:342: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_descriptor" [union-attr]
bleak/backends/corebluetooth/client.py:346: error: "NSData" has no attribute "initWithBytes_length_" [attr-defined]
bleak/backends/corebluetooth/client.py:346: error: Argument 1 to "len" has incompatible type "Buffer"; expected "Sized" [arg-type]
bleak/backends/corebluetooth/client.py:347: error: Item "None" of "PeripheralDelegate | None" has no attribute "write_descriptor" [union-attr]
bleak/backends/corebluetooth/client.py:376: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_characteristic" [union-attr]
bleak/backends/corebluetooth/client.py:380: error: Argument 1 to "BleakCharacteristicNotFoundError" has incompatible type "BleakGATTCharacteristic | int | str | UUID"; expected "int | str | UUID" [arg-type]
bleak/backends/corebluetooth/client.py:382: error: Item "None" of "PeripheralDelegate | None" has no attribute "stop_notifications" [union-attr]
bleak/backends/corebluetooth/client.py:386: error: Item "None" of "PeripheralDelegate | None" has no attribute "read_rssi" [union-attr]
bleak/backends/bluezdbus/client.py:134: error: Unexpected keyword argument "adapter" for "find_device_by_address" of "BleakScanner" [call-arg]
bleak/__init__.py:370: note: "find_device_by_address" of "BleakScanner" defined here
bleak/backends/bluezdbus/client.py:297: error: Argument 1 to "assert_reply" has incompatible type "Message | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/client.py:417: error: Argument 1 to "assert_reply" has incompatible type "Message | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/client.py:440: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/client.py:450: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/client.py:451: error: Item "None" of "Message | Any | None" has no attribute "body" [union-attr]
bleak/backends/bluezdbus/client.py:456: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/client.py:466: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/client.py:470: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/client.py:478: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/client.py:480: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/client.py:490: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/client.py:492: error: Item "None" of "Message | Any | None" has no attribute "body" [union-attr]
bleak/backends/bluezdbus/client.py:522: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/client.py:532: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/client.py:550: error: Incompatible return value type (got "_DeprecatedIsConnectedReturn", expected "bool") [return-value]
bleak/backends/bluezdbus/client.py:570: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "characteristics" [union-attr]
bleak/backends/bluezdbus/client.py:577: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "characteristics" [union-attr]
bleak/backends/bluezdbus/client.py:581: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/client.py:584: error: Item "BleakGATTCharacteristic" of "BleakGATTCharacteristic | Any" has no attribute "path" [union-attr]
bleak/backends/bluezdbus/client.py:591: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/client.py:594: error: Item "None" of "Message | Any | None" has no attribute "unix_fds" [union-attr]
bleak/backends/bluezdbus/client.py:595: error: Item "None" of "Message | Any | None" has no attribute "body" [union-attr]
bleak/backends/bluezdbus/client.py:671: error: Argument 1 of "read_gatt_char" is incompatible with supertype "BaseBleakClient"; supertype defines the argument type as "BleakGATTCharacteristic | int | str | UUID" [override]
bleak/backends/bluezdbus/client.py:671: note: This violates the Liskov substitution principle
bleak/backends/bluezdbus/client.py:671: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/bluezdbus/client.py:689: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_characteristic" [union-attr]
bleak/backends/bluezdbus/client.py:700: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/client.py:710: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/client.py:712: error: Item "None" of "Message | Any | None" has no attribute "body" [union-attr]
bleak/backends/bluezdbus/client.py:733: error: Argument 1 to "BleakCharacteristicNotFoundError" has incompatible type "BleakGATTCharacteristicBlueZDBus | int | str | UUID"; expected "int | str | UUID" [arg-type]
bleak/backends/bluezdbus/client.py:741: error: Item "BleakGATTCharacteristic" of "BleakGATTCharacteristic | Any" has no attribute "path" [union-attr]
bleak/backends/bluezdbus/client.py:765: error: Item "BleakGATTCharacteristic" of "BleakGATTCharacteristic | Any" has no attribute "path" [union-attr]
bleak/backends/bluezdbus/client.py:783: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_descriptor" [union-attr]
bleak/backends/bluezdbus/client.py:793: error: Item "BleakGATTDescriptor" of "BleakGATTDescriptor | Any" has no attribute "path" [union-attr]
bleak/backends/bluezdbus/client.py:815: error: Item "BleakGATTDescriptor" of "BleakGATTDescriptor | Any" has no attribute "path" [union-attr]
bleak/backends/bluezdbus/client.py:838: error: "BleakGATTCharacteristic" has no attribute "path" [attr-defined]
bleak/backends/bluezdbus/client.py:868: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/client.py:871: error: "BleakGATTCharacteristic" has no attribute "path" [attr-defined]
bleak/backends/bluezdbus/client.py:878: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/client.py:879: error: Item "None" of "Message | Any | None" has no attribute "unix_fds" [union-attr]
bleak/backends/bluezdbus/client.py:888: error: "BleakGATTCharacteristic" has no attribute "path" [attr-defined]
bleak/backends/bluezdbus/client.py:903: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_descriptor" [union-attr]
bleak/backends/bluezdbus/client.py:914: error: Item "BleakGATTDescriptor" of "BleakGATTDescriptor | Any" has no attribute "path" [union-attr]
bleak/backends/bluezdbus/client.py:934: error: Item "BleakGATTDescriptor" of "BleakGATTDescriptor | Any" has no attribute "path" [union-attr]
bleak/backends/bluezdbus/client.py:959: error: Argument 1 to "assert_reply" has incompatible type "Message | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/client.py:963: error: Argument 1 of "stop_notify" is incompatible with supertype "BaseBleakClient"; supertype defines the argument type as "BleakGATTCharacteristic | int | str | UUID" [override]
bleak/backends/bluezdbus/client.py:963: note: This violates the Liskov substitution principle
bleak/backends/bluezdbus/client.py:963: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/bluezdbus/client.py:977: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_characteristic" [union-attr]
bleak/backends/bluezdbus/client.py:981: error: Argument 1 to "BleakCharacteristicNotFoundError" has incompatible type "BleakGATTCharacteristicBlueZDBus | int | str | UUID"; expected "int | str | UUID" [arg-type]
bleak/backends/bluezdbus/client.py:983: error: Item "None" of "MessageBus | None" has no attribute "call" [union-attr]
bleak/backends/bluezdbus/client.py:986: error: Item "BleakGATTCharacteristic" of "BleakGATTCharacteristic | Any" has no attribute "path" [union-attr]
bleak/backends/bluezdbus/client.py:991: error: Argument 1 to "assert_reply" has incompatible type "Message | Any | None"; expected "Message" [arg-type]
bleak/backends/bluezdbus/client.py:993: error: Item "BleakGATTCharacteristic" of "BleakGATTCharacteristic | Any" has no attribute "path" [union-attr]
bleak/backends/p4android/client.py:11: error: Cannot find implementation or library stub for module named "android.broadcast" [import-not-found]
bleak/backends/p4android/client.py:12: error: Cannot find implementation or library stub for module named "jnius" [import-not-found]
bleak/backends/p4android/client.py:79: error: Need type annotation for "_subscriptions" (hint: "_subscriptions: Dict[<type>, <type>] = ...") [var-annotated]
bleak/backends/p4android/client.py:103: error: "None" has no attribute "requestMtu" [attr-defined]
bleak/backends/p4android/client.py:110: error: "None" has no attribute "discoverServices" [attr-defined]
bleak/backends/p4android/client.py:242: error: Signature of "mtu_size" incompatible with supertype "BaseBleakClient" [override]
bleak/backends/p4android/client.py:242: note: Superclass:
bleak/backends/p4android/client.py:242: note: int
bleak/backends/p4android/client.py:242: note: Subclass:
bleak/backends/p4android/client.py:242: note: int | None
bleak/backends/p4android/client.py:247: error: Signature of "get_services" incompatible with supertype "BaseBleakClient" [override]
bleak/backends/p4android/client.py:247: note: Superclass:
bleak/backends/p4android/client.py:247: note: def get_services(self, **kwargs: Any) -> Coroutine[Any, Any, BleakGATTServiceCollection]
bleak/backends/p4android/client.py:247: note: Subclass:
bleak/backends/p4android/client.py:247: note: def get_services(self) -> Coroutine[Any, Any, BleakGATTServiceCollection]
bleak/backends/p4android/client.py:260: error: "None" has no attribute "getServices" [attr-defined]
bleak/backends/p4android/client.py:299: error: Argument 1 of "read_gatt_char" is incompatible with supertype "BaseBleakClient"; supertype defines the argument type as "BleakGATTCharacteristic | int | str | UUID" [override]
bleak/backends/p4android/client.py:299: note: This violates the Liskov substitution principle
bleak/backends/p4android/client.py:299: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/p4android/client.py:314: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_characteristic" [union-attr]
bleak/backends/p4android/client.py:319: error: Argument 1 to "BleakCharacteristicNotFoundError" has incompatible type "BleakGATTCharacteristicP4Android | int | str | UUID"; expected "int | str | UUID" [arg-type]
bleak/backends/p4android/client.py:322: error: "None" has no attribute "readCharacteristic" [attr-defined]
bleak/backends/p4android/client.py:334: error: Argument 1 of "read_gatt_descriptor" is incompatible with supertype "BaseBleakClient"; supertype defines the argument type as "int" [override]
bleak/backends/p4android/client.py:334: note: This violates the Liskov substitution principle
bleak/backends/p4android/client.py:334: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/p4android/client.py:349: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_descriptor" [union-attr]
bleak/backends/p4android/client.py:349: error: Argument 1 to "get_descriptor" of "BleakGATTServiceCollection" has incompatible type "str | UUID"; expected "int" [arg-type]
bleak/backends/p4android/client.py:357: error: "None" has no attribute "readDescriptor" [attr-defined]
bleak/backends/p4android/client.py:372: error: Argument 2 of "write_gatt_char" is incompatible with supertype "BaseBleakClient"; supertype defines the argument type as "Buffer" [override]
bleak/backends/p4android/client.py:372: note: This violates the Liskov substitution principle
bleak/backends/p4android/client.py:372: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/p4android/client.py:387: error: "None" has no attribute "writeCharacteristic" [attr-defined]
bleak/backends/p4android/client.py:398: error: Argument 1 of "write_gatt_descriptor" is incompatible with supertype "BaseBleakClient"; supertype defines the argument type as "int" [override]
bleak/backends/p4android/client.py:398: note: This violates the Liskov substitution principle
bleak/backends/p4android/client.py:398: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/p4android/client.py:399: error: Argument 2 of "write_gatt_descriptor" is incompatible with supertype "BaseBleakClient"; supertype defines the argument type as "Buffer" [override]
bleak/backends/p4android/client.py:399: note: This violates the Liskov substitution principle
bleak/backends/p4android/client.py:399: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/p4android/client.py:411: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_descriptor" [union-attr]
bleak/backends/p4android/client.py:411: error: Argument 1 to "get_descriptor" of "BleakGATTServiceCollection" has incompatible type "str | UUID"; expected "int" [arg-type]
bleak/backends/p4android/client.py:421: error: "None" has no attribute "writeDescriptor" [attr-defined]
bleak/backends/p4android/client.py:455: error: Argument 1 of "stop_notify" is incompatible with supertype "BaseBleakClient"; supertype defines the argument type as "BleakGATTCharacteristic | int | str | UUID" [override]
bleak/backends/p4android/client.py:455: note: This violates the Liskov substitution principle
bleak/backends/p4android/client.py:455: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
bleak/backends/p4android/client.py:466: error: Item "None" of "BleakGATTServiceCollection | None" has no attribute "get_characteristic" [union-attr]
bleak/backends/p4android/client.py:470: error: Argument 1 to "BleakCharacteristicNotFoundError" has incompatible type "BleakGATTCharacteristicP4Android | int | str | UUID"; expected "int | str | UUID" [arg-type]
bleak/backends/p4android/client.py:473: error: Item "BleakGATTCharacteristic" of "BleakGATTCharacteristic | Any" has no attribute "notification_descriptor" [union-attr]
bleak/backends/p4android/client.py:477: error: "None" has no attribute "setCharacteristicNotification" [attr-defined]
examples/two_devices.py:46: error: Unexpected keyword argument "macos" for "find_device_by_address" of "BleakScanner" [call-arg]
bleak/__init__.py:370: note: "find_device_by_address" of "BleakScanner" defined here
examples/async_callback_with_queue.py:76: error: Need type annotation for "queue" [var-annotated]
examples/kivy/main.py:4: error: Cannot find implementation or library stub for module named "kivy.app" [import-not-found]
examples/kivy/main.py:7: error: Cannot find implementation or library stub for module named "kivy.uix.label" [import-not-found]
examples/kivy/main.py:8: error: Cannot find implementation or library stub for module named "kivy.uix.scrollview" [import-not-found]
examples/kivy/main.py:11: error: Cannot find implementation or library stub for module named "kivy.logger" [import-not-found]
Found 289 errors in 37 files (checked 74 source files)
Then again, there is some low-hanging fruit. For example, users are frequently allowed to use int, str, or uuid to specify BLE resources. This is counterproductive - the user should be forced to put their int, str, or uuid into the correct type. This converts a runtime error into a "squiggle" in the code editor, all while relieving pressure on the documentation.
That said, it must be approached without changing the existing API. Maybe not so easy.
bluetoothctl -v
) in case of Linux: not relevantDescription
At PyCon 2022, we're sprinting to improve type annotations in the adafruit circuitpython libraries. bleak is one of the foundational libraries in the adafruit bluetooth stack, and so we can't quite get complete typing without bleak also having complete typing (or alternatively, stubs).
Is there interest in improved typing? We could produce a PR, but I wanted to check if that would be likely to be accepted first!
What I Did
Found 85 errors in 22 files (let me know if you'd like the full output pasted here)