6
6
7
7
from typing import Any , Dict , Iterable , Iterator , List , Optional , Sequence , Union
8
8
9
+ import can .typechecking
10
+
9
11
from abc import ABCMeta , abstractmethod
10
12
import can
11
13
import logging
@@ -43,7 +45,7 @@ class BusABC(metaclass=ABCMeta):
43
45
def __init__ (
44
46
self ,
45
47
channel : Any ,
46
- can_filters : Optional [List [ Dict [ str , Union [ bool , int , str ]]]] = None ,
48
+ can_filters : Optional [can . typechecking . CanFilters ] ,
47
49
** kwargs : object
48
50
):
49
51
"""Construct and open a CAN bus instance of the specified type.
@@ -317,12 +319,10 @@ def filters(self) -> Optional[Iterable[dict]]:
317
319
return self ._filters
318
320
319
321
@filters .setter
320
- def filters (self , filters : Optional [Iterable [ Dict [ str , Union [ bool , int , str ]]] ]):
322
+ def filters (self , filters : Optional [can . typechecking . CanFilters ]):
321
323
self .set_filters (filters )
322
324
323
- def set_filters (
324
- self , filters : Optional [Iterable [Dict [str , Union [bool , int , str ]]]] = None
325
- ):
325
+ def set_filters (self , filters : Optional [can .typechecking .CanFilters ]):
326
326
"""Apply filtering to all messages received by this Bus.
327
327
328
328
All messages that match at least one filter are returned.
@@ -347,9 +347,7 @@ def set_filters(
347
347
self ._filters = filters or None
348
348
self ._apply_filters (self ._filters )
349
349
350
- def _apply_filters (
351
- self , filters : Optional [Iterable [Dict [str , Union [bool , int , str ]]]]
352
- ):
350
+ def _apply_filters (self , filters : Optional [can .typechecking .CanFilters ]):
353
351
"""
354
352
Hook for applying the filters to the underlying kernel or
355
353
hardware if supported/implemented by the interface.
0 commit comments