Skip to content

Commit ad21cb6

Browse files
committed
* build_and_test.yml workflow_dispatch trigger added
* legacy `collections.abc` imports replacement with `typing_extensions` cause current minimum `typing_extensions>=4.7` version already supports it * removed deprecated imports from __future__ * Undefined annotations fixed
1 parent 6b2c390 commit ad21cb6

File tree

21 files changed

+64
-102
lines changed

21 files changed

+64
-102
lines changed

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
pull_request:
88
branches: [ master, develop ]
99
paths: [ 'bleak/**', 'tests/**' ]
10+
workflow_dispatch:
1011

1112
jobs:
1213
build_desktop:

bleak/__init__.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
"""Top-level package for bleak."""
44

5-
from __future__ import annotations
6-
75
__author__ = """Henrik Blidh"""
86
__email__ = "[email protected]"
97

@@ -14,21 +12,27 @@
1412
import os
1513
import sys
1614
import uuid
17-
from collections.abc import AsyncGenerator, Awaitable, Callable, Iterable
1815
from types import TracebackType
19-
from typing import Any, Literal, Optional, TypedDict, Union, cast, overload
16+
from typing import (
17+
Any,
18+
AsyncGenerator,
19+
Awaitable,
20+
Callable,
21+
Iterable,
22+
Literal,
23+
Optional,
24+
TypedDict,
25+
Union,
26+
cast,
27+
overload,
28+
)
2029

21-
if sys.version_info < (3, 12):
22-
from typing_extensions import Buffer
23-
else:
24-
from collections.abc import Buffer
30+
from typing_extensions import Buffer, Never, Self, Unpack, assert_never
2531

2632
if sys.version_info < (3, 11):
2733
from async_timeout import timeout as async_timeout
28-
from typing_extensions import Never, Self, Unpack, assert_never
2934
else:
3035
from asyncio import timeout as async_timeout
31-
from typing import Never, Self, Unpack, assert_never
3236

3337
from bleak.args.bluez import BlueZScannerArgs
3438
from bleak.args.corebluetooth import CBScannerArgs, CBStartNotifyArgs
@@ -481,7 +485,7 @@ class BleakClient:
481485
def __init__(
482486
self,
483487
address_or_ble_device: Union[BLEDevice, str],
484-
disconnected_callback: Optional[Callable[[BleakClient], None]] = None,
488+
disconnected_callback: Optional[Callable[["BleakClient"], None]] = None,
485489
services: Optional[Iterable[str]] = None,
486490
*,
487491
timeout: float = 10.0,

bleak/args/corebluetooth.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
-------------------------------
55
"""
66

7-
from collections.abc import Callable
8-
from typing import Optional, TypedDict
7+
from typing import Callable, Optional, TypedDict
98

109

1110
class CBScannerArgs(TypedDict, total=False):

bleak/backends/bluezdbus/advertisement_monitor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
assert False, "This backend is only available on Linux"
1515

1616
import logging
17-
from collections.abc import Iterable
18-
from typing import Any, no_type_check
17+
from typing import Any, Iterable, no_type_check
1918
from warnings import warn
2019

2120
from dbus_fast import PropertyAccess

bleak/backends/bluezdbus/client.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,10 @@
1313
import logging
1414
import os
1515
import warnings
16-
from collections.abc import Callable
1716
from contextlib import AsyncExitStack
18-
from typing import Any, Optional, Union
17+
from typing import Any, Callable, Optional, Union
1918

20-
if sys.version_info < (3, 12):
21-
from typing_extensions import Buffer, override
22-
else:
23-
from collections.abc import Buffer
24-
from typing import override
19+
from typing_extensions import Buffer, override
2520

2621
if sys.version_info < (3, 11):
2722
from async_timeout import timeout as async_timeout

bleak/backends/bluezdbus/manager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
import logging
1919
import os
2020
from collections import defaultdict
21-
from collections.abc import Callable, Coroutine, MutableMapping
22-
from typing import Any, NamedTuple, Optional, cast
21+
from typing import Any, Callable, Coroutine, MutableMapping, NamedTuple, Optional, cast
2322
from weakref import WeakKeyDictionary
2423

2524
from dbus_fast import BusType, Message, MessageType, Variant, unpack_variants

bleak/backends/bluezdbus/scanner.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66
assert False, "This backend is only available on Linux"
77

88
import logging
9-
from collections.abc import Callable, Coroutine
10-
from typing import Any, Literal, Optional
9+
from typing import Any, Callable, Coroutine, Literal, Optional
1110
from warnings import warn
1211

13-
if sys.version_info < (3, 12):
14-
from typing_extensions import override
15-
else:
16-
from typing import override
17-
1812
from dbus_fast import Variant
13+
from typing_extensions import override
1914

2015
from bleak.args.bluez import BlueZDiscoveryFilters as _BlueZDiscoveryFilters
2116
from bleak.args.bluez import BlueZScannerArgs as _BlueZScannerArgs

bleak/backends/bluezdbus/signals.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import annotations
3-
42
import sys
53
from typing import TYPE_CHECKING
64

@@ -144,7 +142,7 @@ def __init__(
144142
self.args = None
145143

146144
@staticmethod
147-
def parse(rules: str) -> MatchRules:
145+
def parse(rules: str) -> "MatchRules":
148146
return MatchRules(**dict(r.split("=") for r in rules.split(",")))
149147

150148
def __str__(self) -> str:

bleak/backends/characteristic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
from __future__ import annotations
77

88
import enum
9-
from collections.abc import Callable
10-
from typing import TYPE_CHECKING, Any, Union
9+
from typing import TYPE_CHECKING, Any, Callable, Union
1110
from uuid import UUID
1211

1312
from bleak.assigned_numbers import CharacteristicPropertyName

bleak/backends/client.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@
77
import os
88
import platform
99
import sys
10-
from collections.abc import Callable
11-
from typing import Any, Optional, Union
10+
from typing import Any, Callable, Optional, Union
1211

13-
if sys.version_info < (3, 12):
14-
from typing_extensions import Buffer
15-
else:
16-
from collections.abc import Buffer
12+
from typing_extensions import Buffer
1713

1814
from bleak.backends.characteristic import BleakGATTCharacteristic
1915
from bleak.backends.descriptor import BleakGATTDescriptor

0 commit comments

Comments
 (0)