Skip to content

Commit

Permalink
refactor: narrow down SuperEnum to StrEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
sujuka99 committed Sep 22, 2023
1 parent fd702f0 commit b3b01b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions hooks/gen_docs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@

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
either containing all items, only their names or their values.
"""

@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)

Expand Down
4 changes: 2 additions & 2 deletions hooks/gen_docs/gen_docs_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit b3b01b9

Please sign in to comment.