Skip to content

Commit

Permalink
refactor: Inherit from str, Enum instead of StrEnum which needs a…
Browse files Browse the repository at this point in the history
… backport

Issue-307: #307
  • Loading branch information
pawamoy committed Jul 16, 2024
1 parent 1a7bbb6 commit 77f1544
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ classifiers = [
]
dependencies = [
"astunparse>=1.6; python_version < '3.9'",
"backports-strenum>=1.3; python_version < '3.11'",
"colorama>=0.4",
]

Expand Down
27 changes: 10 additions & 17 deletions src/_griffe/enumerations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@

from __future__ import annotations

import sys
from enum import IntEnum
from enum import Enum

# YORE: Bump 1: Replace block with line 2.
if sys.version_info >= (3, 11):
from enum import StrEnum
else:
from backports.strenum import StrEnum


class LogLevel(StrEnum):
class LogLevel(str, Enum):
"""Enumeration of available log levels."""

trace: str = "trace"
Expand All @@ -31,7 +24,7 @@ class LogLevel(StrEnum):
"""The CRITICAL log level."""


class DocstringSectionKind(StrEnum):
class DocstringSectionKind(str, Enum):
"""Enumeration of the possible docstring section kinds."""

text = "text"
Expand Down Expand Up @@ -66,7 +59,7 @@ class DocstringSectionKind(StrEnum):
"""Admonition block."""


class ParameterKind(StrEnum):
class ParameterKind(str, Enum):
"""Enumeration of the different parameter kinds."""

positional_only: str = "positional-only"
Expand All @@ -81,7 +74,7 @@ class ParameterKind(StrEnum):
"""Variadic keyword parameter."""


class Kind(StrEnum):
class Kind(str, Enum):
"""Enumeration of the different object kinds."""

MODULE: str = "module"
Expand All @@ -96,7 +89,7 @@ class Kind(StrEnum):
"""Aliases (imported objects)."""


class ExplanationStyle(StrEnum):
class ExplanationStyle(str, Enum):
"""Enumeration of the possible styles for explanations."""

ONE_LINE: str = "oneline"
Expand All @@ -109,7 +102,7 @@ class ExplanationStyle(StrEnum):
"""Explanation as GitHub workflow commands warnings, adapted to CI."""


class BreakageKind(StrEnum):
class BreakageKind(str, Enum):
"""Enumeration of the possible API breakages."""

PARAMETER_MOVED: str = "Positional parameter was moved"
Expand Down Expand Up @@ -138,7 +131,7 @@ class BreakageKind(StrEnum):
"""Base class was removed"""


class Parser(StrEnum):
class Parser(str, Enum):
"""Enumeration of the different docstring parsers."""

google = "google"
Expand All @@ -149,7 +142,7 @@ class Parser(StrEnum):
"""Numpydoc-style docstrings parser."""


class ObjectKind(StrEnum):
class ObjectKind(str, Enum):
"""Enumeration of the different runtime object kinds."""

MODULE: str = "module"
Expand Down Expand Up @@ -184,7 +177,7 @@ def __str__(self) -> str:


# YORE: Bump 1: Remove block.
class When(IntEnum):
class When(int, Enum):
"""Enumeration of the different times at which an extension is used.
Deprecated. This enumeration is used with the `VisitorExtension` and `InspectorExtension` classes,
Expand Down

0 comments on commit 77f1544

Please sign in to comment.