From bc6def17e4ea7b1b8b19a26f6abb0521a15ff194 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 1 Jun 2023 13:08:21 +0200 Subject: [PATCH] Get rid of unnecessary usage of TypeVar --- mkosi/__init__.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 11848da5e..c8bd9b09e 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -19,7 +19,7 @@ import uuid from collections.abc import Iterator, Sequence from pathlib import Path from textwrap import dedent -from typing import Callable, ContextManager, Optional, TextIO, TypeVar, Union, cast +from typing import Callable, ContextManager, Optional, TextIO, Union, cast from mkosi.btrfs import btrfs_maybe_snapshot_subvolume from mkosi.config import ( @@ -57,9 +57,6 @@ MKOSI_COMMANDS_NEED_BUILD = (Verb.build, Verb.shell, Verb.boot, Verb.qemu, Verb. MKOSI_COMMANDS_SUDO = (Verb.shell, Verb.boot) -T = TypeVar("T") - - @contextlib.contextmanager def mount_image(state: MkosiState) -> Iterator[None]: with complete_step("Mounting image…", "Unmounting image…"), contextlib.ExitStack() as stack: @@ -1213,16 +1210,16 @@ def yes_no_auto(f: ConfigFeature) -> str: return "auto" if f is ConfigFeature.auto else yes_no(f == ConfigFeature.enabled) -def none_to_na(s: Optional[T]) -> Union[T, str]: - return "n/a" if s is None else s +def none_to_na(s: Optional[object]) -> str: + return "n/a" if s is None else str(s) -def none_to_none(s: Optional[T]) -> Union[T, str]: - return "none" if s is None else s +def none_to_none(s: Optional[object]) -> str: + return "none" if s is None else str(s) -def none_to_default(s: Optional[T]) -> Union[T, str]: - return "default" if s is None else s +def none_to_default(s: Optional[object]) -> str: + return "default" if s is None else str(s) def path_or_none( -- 2.47.2