From b3b01b9c4eacfc2f9d59bacc8a410142014df0d1 Mon Sep 17 00:00:00 2001 From: Ivan Yordanov Date: Fri, 22 Sep 2023 13:45:59 +0300 Subject: [PATCH] refactor: narrow down SuperEnum to StrEnum --- hooks/gen_docs/__init__.py | 8 +++----- hooks/gen_docs/gen_docs_env_vars.py | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/hooks/gen_docs/__init__.py b/hooks/gen_docs/__init__.py index dea4b3065..8d5328456 100644 --- a/hooks/gen_docs/__init__.py +++ b/hooks/gen_docs/__init__.py @@ -2,12 +2,10 @@ from collections.abc import Generator from enum import Enum -from typing import Any, Generic, TypeVar +from typing import Any -_T = TypeVar("_T") - -class SuperEnum(Generic[_T], Enum): +class StrEnum(str, Enum): """Adds constructors that return all items in a ``Generator``. Introduces constructors that return a ``Generator`` object @@ -15,7 +13,7 @@ class SuperEnum(Generic[_T], Enum): """ @classmethod - def items(cls) -> Generator[tuple[Any, _T], None, None]: + def items(cls) -> Generator[tuple[Any, str], None, None]: """Return all item names and values in tuples.""" return ((e.name, e.value) for e in cls) diff --git a/hooks/gen_docs/gen_docs_env_vars.py b/hooks/gen_docs/gen_docs_env_vars.py index 8ed16fd87..c7b122cf8 100644 --- a/hooks/gen_docs/gen_docs_env_vars.py +++ b/hooks/gen_docs/gen_docs_env_vars.py @@ -19,7 +19,7 @@ from typing_extensions import Self from hooks import PATH_ROOT -from hooks.gen_docs import SuperEnum +from hooks.gen_docs import StrEnum from kpops.cli import main from kpops.cli.pipeline_config import PipelineConfig @@ -92,7 +92,7 @@ def from_record(cls, record: dict[str, Any]) -> Self: ) -class EnvVarAttrs(str, SuperEnum): +class EnvVarAttrs(StrEnum): """The attr names are used as columns for the markdown tables.""" NAME = "Name"