diff --git a/findmy/keys.py b/findmy/keys.py index 6a8188b..b899616 100644 --- a/findmy/keys.py +++ b/findmy/keys.py @@ -233,10 +233,10 @@ class KeyPair(HasPublicKey, Serializable[KeyPairMapping]): return f'KeyPair(name="{self.name}", public_key="{self.adv_key_b64}", type={self.key_type})' -K = TypeVar("K") +_K = TypeVar("_K") -class KeyGenerator(ABC, Generic[K]): +class KeyGenerator(ABC, Generic[_K]): """KeyPair generator.""" @abstractmethod @@ -244,17 +244,17 @@ class KeyGenerator(ABC, Generic[K]): return NotImplemented @abstractmethod - def __next__(self) -> K: + def __next__(self) -> _K: return NotImplemented @overload @abstractmethod - def __getitem__(self, val: int) -> K: ... + def __getitem__(self, val: int) -> _K: ... @overload @abstractmethod - def __getitem__(self, val: slice) -> Generator[K, None, None]: ... + def __getitem__(self, val: slice) -> Generator[_K, None, None]: ... @abstractmethod - def __getitem__(self, val: int | slice) -> K | Generator[K, None, None]: + def __getitem__(self, val: int | slice) -> _K | Generator[_K, None, None]: return NotImplemented diff --git a/findmy/util/files.py b/findmy/util/files.py index e58bfd9..1686bbf 100644 --- a/findmy/util/files.py +++ b/findmy/util/files.py @@ -7,10 +7,10 @@ from collections.abc import Mapping from pathlib import Path from typing import TypeVar, cast -T = TypeVar("T", bound=Mapping) +_T = TypeVar("_T", bound=Mapping) -def save_and_return_json(data: T, dst: str | Path | None) -> T: +def save_and_return_json(data: _T, dst: str | Path | None) -> _T: """Save and return a JSON-serializable data structure.""" if dst is None: return data @@ -23,12 +23,12 @@ def save_and_return_json(data: T, dst: str | Path | None) -> T: return data -def read_data_json(val: str | Path | T) -> T: +def read_data_json(val: str | Path | _T) -> _T: """Read JSON data from a file if a path is passed, or return the argument itself.""" if isinstance(val, str): val = Path(val) if isinstance(val, Path): - val = cast("T", json.loads(val.read_text())) + val = cast("_T", json.loads(val.read_text())) return val diff --git a/findmy/util/types.py b/findmy/util/types.py index 9326eda..370ad61 100644 --- a/findmy/util/types.py +++ b/findmy/util/types.py @@ -3,8 +3,8 @@ from collections.abc import Coroutine from typing import TypeVar, Union -T = TypeVar("T") +_T = TypeVar("_T") # Cannot use `|` operator (PEP 604) in python 3.9, # even with __future__ import since it is evaluated directly -MaybeCoro = Union[T, Coroutine[None, None, T]] +MaybeCoro = Union[_T, Coroutine[None, None, _T]]