Add type annotation to device_list
This commit is contained in:
@@ -6,6 +6,7 @@ try:
|
||||
if TYPE_CHECKING:
|
||||
import datetime
|
||||
from internalblue.hci import HCI
|
||||
from internalblue.core import InternalBlue
|
||||
Address = NewType("Address", int)
|
||||
Record = Tuple[HCI, int, int, int, Any, datetime.datetime]
|
||||
FilterFunction = Callable[[Record], bool]
|
||||
@@ -26,6 +27,8 @@ try:
|
||||
"dev_bdaddr": dev_bdaddr,
|
||||
"dev_flags": dev_flags,
|
||||
"dev_flags_str": dev_flags_str}"""
|
||||
# InternalBlueCore, Device Name, SomeString
|
||||
DeviceTuple = Tuple[InternalBlue, str, str]
|
||||
|
||||
|
||||
except:
|
||||
|
||||
+5
-2
@@ -41,8 +41,9 @@ from . import cmds
|
||||
|
||||
try:
|
||||
import typing
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
from internalblue.core import InternalBlue
|
||||
from . import DeviceTuple
|
||||
|
||||
except:
|
||||
pass
|
||||
@@ -152,10 +153,12 @@ def internalblue_cli(argv):
|
||||
ADBCore(log_level=log_level, data_directory=data_directory, serial=args.serialsu),
|
||||
HCICore(log_level=log_level, data_directory=data_directory)]
|
||||
|
||||
devices = []
|
||||
devices = [] # type: List[DeviceTuple]
|
||||
for connection_method in connection_methods:
|
||||
devices.extend(connection_method.device_list())
|
||||
|
||||
|
||||
device = None # type: Optional[DeviceTuple]
|
||||
if len(devices) > 0:
|
||||
if len(devices) == 1:
|
||||
device = devices[0]
|
||||
|
||||
@@ -39,7 +39,7 @@ try:
|
||||
from internalblue import Address, Record, Task, HCI_CMD, FilterFunction, ConnectionNumber, ConnectionDict, \
|
||||
ConnectionIndex, BluetoothAddress, HeapInformation, QueueInformation, Opcode
|
||||
from internalblue.hci import HCI
|
||||
|
||||
from . import DeviceTuple
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
except:
|
||||
@@ -496,7 +496,7 @@ class InternalBlue:
|
||||
|
||||
@abstractmethod
|
||||
def device_list(self):
|
||||
# type: () -> List[Tuple[InternalBlue,Any,str]]
|
||||
# type: () -> List[DeviceTuple]
|
||||
pass
|
||||
|
||||
def connect(self):
|
||||
|
||||
Reference in New Issue
Block a user