File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111from time import time
1212from types import TracebackType
1313from typing import (
14- Any ,
1514 Callable ,
1615 Optional ,
1716 Union ,
@@ -69,7 +68,7 @@ class BusABC(metaclass=ABCMeta):
6968 @abstractmethod
7069 def __init__ (
7170 self ,
72- channel : Any ,
71+ channel : Optional [ can . typechecking . Channel ] ,
7372 can_filters : Optional [can .typechecking .CanFilters ] = None ,
7473 ** kwargs : object ,
7574 ):
Original file line number Diff line number Diff line change 1212from copy import deepcopy
1313from random import randint
1414from threading import RLock
15- from typing import TYPE_CHECKING , Any , Optional
15+ from typing import Any , Optional
1616
1717from can import CanOperationError
1818from can .bus import BusABC , CanProtocol
1919from can .message import Message
20- from can .typechecking import AutoDetectedConfig
20+ from can .typechecking import AutoDetectedConfig , Channel
2121
2222logger = logging .getLogger (__name__ )
2323
2424
2525# Channels are lists of queues, one for each connection
26- if TYPE_CHECKING :
27- # https://mypy.readthedocs.io/en/stable/runtime_troubles.html#using-classes-that-are-generic-in-stubs-but-not-at-runtime
28- channels : dict [Optional [Any ], list [queue .Queue [Message ]]] = {}
29- else :
30- channels = {}
26+ channels : dict [Optional [Channel ], list [queue .Queue [Message ]]] = {}
3127channels_lock = RLock ()
3228
3329
@@ -58,7 +54,7 @@ class VirtualBus(BusABC):
5854
5955 def __init__ (
6056 self ,
61- channel : Any = None ,
57+ channel : Optional [ Channel ] = None ,
6258 receive_own_messages : bool = False ,
6359 rx_queue_size : int = 0 ,
6460 preserve_timestamps : bool = False ,
You can’t perform that action at this time.
0 commit comments