Skip to content

Commit

Permalink
remove typing import
Browse files Browse the repository at this point in the history
  • Loading branch information
zariiii9003 committed Nov 23, 2024
1 parent 2b8154a commit 6fc0d7d
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions can/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
import logging
import threading
import time
import typing
from contextlib import AbstractContextManager
from types import TracebackType
from typing import Any, Awaitable, Callable, Iterable, List, NamedTuple, Optional, Union
from typing import (
Any,
Awaitable,
Callable,
Final,
Iterable,
List,
NamedTuple,
Optional,
Type,
Union,
)

from can.bus import BusABC
from can.listener import Listener
Expand All @@ -34,7 +44,7 @@ class _NotifierRegistry:

def __init__(self) -> None:
"""Initialize the registry with an empty list of bus-notifier pairs and a threading lock."""
self.pairs: typing.List[_BusNotifierPair] = []
self.pairs: List[_BusNotifierPair] = []
self.lock = threading.Lock()

def register(self, bus: BusABC, notifier: "Notifier") -> None:
Expand Down Expand Up @@ -68,7 +78,7 @@ def unregister(self, bus: BusABC, notifier: "Notifier") -> None:
The Notifier instance associated with the bus.
"""
with self.lock:
registered_pairs_to_remove: typing.List[_BusNotifierPair] = []
registered_pairs_to_remove: List[_BusNotifierPair] = []
for pair in self.pairs:
if pair.bus is bus and pair.notifier is notifier:
registered_pairs_to_remove.append(pair)
Expand All @@ -78,7 +88,7 @@ def unregister(self, bus: BusABC, notifier: "Notifier") -> None:

class Notifier(AbstractContextManager):

_registry: typing.Final = _NotifierRegistry()
_registry: Final = _NotifierRegistry()

def __init__(
self,
Expand Down Expand Up @@ -266,7 +276,7 @@ def stopped(self) -> bool:

def __exit__(
self,
exc_type: Optional[typing.Type[BaseException]],
exc_type: Optional[Type[BaseException]],
exc_value: Optional[BaseException],
traceback: Optional[TracebackType],
) -> None:
Expand Down

0 comments on commit 6fc0d7d

Please sign in to comment.