77import logging
88import threading
99import time
10- import typing
1110from contextlib import AbstractContextManager
1211from types import TracebackType
13- from typing import Any , Awaitable , Callable , Iterable , List , NamedTuple , Optional , Union
12+ from typing import (
13+ Any ,
14+ Awaitable ,
15+ Callable ,
16+ Final ,
17+ Iterable ,
18+ List ,
19+ NamedTuple ,
20+ Optional ,
21+ Type ,
22+ Union ,
23+ )
1424
1525from can .bus import BusABC
1626from can .listener import Listener
@@ -34,7 +44,7 @@ class _NotifierRegistry:
3444
3545 def __init__ (self ) -> None :
3646 """Initialize the registry with an empty list of bus-notifier pairs and a threading lock."""
37- self .pairs : typing . List [_BusNotifierPair ] = []
47+ self .pairs : List [_BusNotifierPair ] = []
3848 self .lock = threading .Lock ()
3949
4050 def register (self , bus : BusABC , notifier : "Notifier" ) -> None :
@@ -68,7 +78,7 @@ def unregister(self, bus: BusABC, notifier: "Notifier") -> None:
6878 The Notifier instance associated with the bus.
6979 """
7080 with self .lock :
71- registered_pairs_to_remove : typing . List [_BusNotifierPair ] = []
81+ registered_pairs_to_remove : List [_BusNotifierPair ] = []
7282 for pair in self .pairs :
7383 if pair .bus is bus and pair .notifier is notifier :
7484 registered_pairs_to_remove .append (pair )
@@ -78,7 +88,7 @@ def unregister(self, bus: BusABC, notifier: "Notifier") -> None:
7888
7989class Notifier (AbstractContextManager ):
8090
81- _registry : typing . Final = _NotifierRegistry ()
91+ _registry : Final = _NotifierRegistry ()
8292
8393 def __init__ (
8494 self ,
@@ -266,7 +276,7 @@ def stopped(self) -> bool:
266276
267277 def __exit__ (
268278 self ,
269- exc_type : Optional [typing . Type [BaseException ]],
279+ exc_type : Optional [Type [BaseException ]],
270280 exc_value : Optional [BaseException ],
271281 traceback : Optional [TracebackType ],
272282 ) -> None :
0 commit comments