Skip to content

Commit c628d0a

Browse files
committed
Import typing symbols in the current scope
Typing symbols are very fundamental and can make the code more readable to use them directly. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 138f77a commit c628d0a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/frequenz/channels/experimental/_grouping_latest_value_cache.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55

66

77
import asyncio
8-
import typing
98
from collections.abc import Callable, ItemsView, Iterator, KeysView, Mapping, ValuesView
9+
from typing import Hashable, TypeVar, overload
1010

1111
from typing_extensions import override
1212

1313
from .._receiver import Receiver
1414

15-
ValueT_co = typing.TypeVar("ValueT_co", covariant=True)
15+
ValueT_co = TypeVar("ValueT_co", covariant=True)
1616
"""Covariant type variable for the values cached by the `GroupingLatestValueCache`."""
1717

18-
DefaultT = typing.TypeVar("DefaultT")
18+
DefaultT = TypeVar("DefaultT")
1919
"""Type variable for the default value returned by `GroupingLatestValueCache.get`."""
2020

21-
HashableT = typing.TypeVar("HashableT", bound=typing.Hashable)
21+
HashableT = TypeVar("HashableT", bound=Hashable)
2222
"""Type variable for the keys used to group values in the `GroupingLatestValueCache`."""
2323

2424

@@ -126,12 +126,12 @@ def values(self) -> ValuesView[ValueT_co]:
126126
"""Return an iterator over the latest values received."""
127127
return self._latest_value_by_key.values()
128128

129-
@typing.overload
129+
@overload
130130
def get(self, key: HashableT, default: None = None) -> ValueT_co | None:
131131
"""Return the latest value that has been received for a specific key."""
132132

133133
# MyPy passes this overload as a valid signature, but pylint does not like it.
134-
@typing.overload
134+
@overload
135135
def get( # pylint: disable=signature-differs
136136
self, key: HashableT, default: DefaultT
137137
) -> ValueT_co | DefaultT:
@@ -228,11 +228,11 @@ def __delitem__(self, key: HashableT) -> None:
228228
"""
229229
del self._latest_value_by_key[key]
230230

231-
@typing.overload
231+
@overload
232232
def pop(self, key: HashableT, /) -> ValueT_co | None:
233233
"""Remove the latest value for a specific key and return it."""
234234

235-
@typing.overload
235+
@overload
236236
def pop(self, key: HashableT, /, default: DefaultT) -> ValueT_co | DefaultT:
237237
"""Remove the latest value for a specific key and return it."""
238238

0 commit comments

Comments
 (0)