Skip to content

Commit e4d605b

Browse files
committed
minor type annotation fixes
1 parent 23217c5 commit e4d605b

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

can/bus.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from time import time
1212
from types import TracebackType
1313
from 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
):

can/interfaces/virtual.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,18 @@
1212
from copy import deepcopy
1313
from random import randint
1414
from threading import RLock
15-
from typing import TYPE_CHECKING, Any, Optional
15+
from typing import Any, Optional
1616

1717
from can import CanOperationError
1818
from can.bus import BusABC, CanProtocol
1919
from can.message import Message
20-
from can.typechecking import AutoDetectedConfig
20+
from can.typechecking import AutoDetectedConfig, Channel
2121

2222
logger = 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]]] = {}
3127
channels_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,

0 commit comments

Comments
 (0)