|
2 | 2 |
|
3 | 3 | import logging |
4 | 4 | import threading |
5 | | -from collections.abc import MutableMapping |
6 | | -from typing import Callable, Dict, Final, Iterator, List, Optional, Union |
| 5 | +from collections.abc import Iterator, MutableMapping |
| 6 | +from typing import Callable, Final, Optional, Union |
7 | 7 |
|
8 | 8 | import can |
9 | | -from can import Listener |
10 | 9 |
|
11 | 10 | from canopen.lss import LssMaster |
12 | 11 | from canopen.nmt import NmtMaster |
@@ -40,10 +39,10 @@ def __init__(self, bus: Optional[can.BusABC] = None): |
40 | 39 | self.scanner = NodeScanner(self) |
41 | 40 | #: List of :class:`can.Listener` objects. |
42 | 41 | #: Includes at least MessageListener. |
43 | | - self.listeners = [MessageListener(self)] |
| 42 | + self.listeners: list[can.Listener] = [MessageListener(self)] |
44 | 43 | self.notifier: Optional[can.Notifier] = None |
45 | | - self.nodes: Dict[int, Union[RemoteNode, LocalNode]] = {} |
46 | | - self.subscribers: Dict[int, List[Callback]] = {} |
| 44 | + self.nodes: dict[int, Union[RemoteNode, LocalNode]] = {} |
| 45 | + self.subscribers: dict[int, list[Callback]] = {} |
47 | 46 | self.send_lock = threading.Lock() |
48 | 47 | self.sync = SyncProducer(self) |
49 | 48 | self.time = TimeProducer(self) |
@@ -352,7 +351,7 @@ def update(self, data: bytes) -> None: |
352 | 351 | self._start() |
353 | 352 |
|
354 | 353 |
|
355 | | -class MessageListener(Listener): |
| 354 | +class MessageListener(can.Listener): |
356 | 355 | """Listens for messages on CAN bus and feeds them to a Network instance. |
357 | 356 |
|
358 | 357 | :param network: |
@@ -396,7 +395,7 @@ def __init__(self, network: Optional[Network] = None): |
396 | 395 | network = _UNINITIALIZED_NETWORK |
397 | 396 | self.network: Network = network |
398 | 397 | #: A :class:`list` of nodes discovered |
399 | | - self.nodes: List[int] = [] |
| 398 | + self.nodes: list[int] = [] |
400 | 399 |
|
401 | 400 | def on_message_received(self, can_id: int): |
402 | 401 | service = can_id & 0x780 |
|
0 commit comments