Skip to content

Commit c567ae8

Browse files
committed
use __futures__.annotations
1 parent f2bf6b0 commit c567ae8

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

adafruit_ble/__init__.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
building on the native `_bleio` module.
1010
1111
"""
12+
13+
from __future__ import annotations
14+
1215
# pylint: disable=wrong-import-position
16+
1317
import sys
1418

1519
if sys.implementation.name == "circuitpython" and sys.implementation.version[0] <= 4:
@@ -24,10 +28,14 @@
2428
from .advertising import Advertisement
2529

2630
try:
27-
from typing import Optional, Iterator, Union, Tuple, Literal, NoReturn
28-
from circuitpython_typing import ReadableBuffer
29-
from adafruit_ble.uuid import UUID
30-
from adafruit_ble.characteristics import Characteristic
31+
from typing import Optional, Iterator, Union, Tuple, NoReturn, TYPE_CHECKING
32+
from typing_extensions import Literal
33+
34+
if TYPE_CHECKING:
35+
from circuitpython_typing import ReadableBuffer
36+
from adafruit_ble.uuid import UUID
37+
from adafruit_ble.characteristics import Characteristic
38+
3139
except ImportError:
3240
pass
3341

@@ -220,7 +228,7 @@ def start_scan(
220228
interval: float = 0.1,
221229
window: float = 0.1,
222230
minimum_rssi: int = -80,
223-
active: bool = True
231+
active: bool = True,
224232
) -> Iterator[Advertisement]:
225233
"""
226234
Starts scanning. Returns an iterator of advertisement objects of the types given in

adafruit_ble/advertising/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66
Advertising is the first phase of BLE where devices can broadcast
77
"""
88

9+
from __future__ import annotations
10+
911
import struct
1012

1113
try:
12-
from typing import Dict, Any, Union, List, Optional, Type, Literal, TypeVar
13-
from _bleio import ScanEntry
14+
from typing import Dict, Any, Union, List, Optional, Type, TypeVar, TYPE_CHECKING
15+
from typing_extensions import Literal
16+
17+
if TYPE_CHECKING:
18+
from _bleio import ScanEntry
1419

15-
LazyObjectField_GivenClass = TypeVar("LazyObjectField_GivenClass")
20+
LazyObjectField_GivenClass = TypeVar("LazyObjectField_GivenClass")
1621

1722
except ImportError:
1823
pass

adafruit_ble/characteristics/__init__.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@
88
99
"""
1010

11+
from __future__ import annotations
12+
1113
import struct
1214
import _bleio
1315

1416
from ..attributes import Attribute
1517

1618
try:
17-
from typing import Optional, Type, Union, Tuple, Iterable
18-
from circuitpython_typing import ReadableBuffer
19-
from adafruit_ble.uuid import UUID
20-
from adafruit_ble.services import Service
19+
from typing import Optional, Type, Union, Tuple, Iterable, TYPE_CHECKING
20+
21+
if TYPE_CHECKING:
22+
from circuitpython_typing import ReadableBuffer
23+
from adafruit_ble.uuid import UUID
24+
from adafruit_ble.services import Service
25+
2126
except ImportError:
2227
pass
2328

@@ -89,7 +94,7 @@ def __init__(
8994
write_perm: int = Attribute.OPEN,
9095
max_length: Optional[int] = None,
9196
fixed_length: bool = False,
92-
initial_value: Optional[ReadableBuffer] = None
97+
initial_value: Optional[ReadableBuffer] = None,
9398
) -> None:
9499
self.field_name = None # Set by Service during basic binding
95100

@@ -179,7 +184,7 @@ def __init__(
179184
write_perm: int = Attribute.OPEN,
180185
max_length: int = 20,
181186
fixed_length: bool = False,
182-
initial_value: Optional[ReadableBuffer] = None
187+
initial_value: Optional[ReadableBuffer] = None,
183188
) -> None:
184189
self.field_name = None # Set by Service during basic binding
185190

@@ -240,7 +245,7 @@ def __init__(
240245
properties: int = 0,
241246
read_perm: int = Attribute.OPEN,
242247
write_perm: int = Attribute.OPEN,
243-
initial_value: Optional[ReadableBuffer] = None
248+
initial_value: Optional[ReadableBuffer] = None,
244249
) -> None:
245250
self._struct_format = struct_format
246251
self._expected_size = struct.calcsize(struct_format)

0 commit comments

Comments
 (0)