Skip to content

Commit

Permalink
Workaround StrEnum incompatibility in 3.10 and 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
GDYendell committed Jul 10, 2024
1 parent 8693912 commit d93a69c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/pvi/_format/widget.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

import sys
from collections.abc import Callable
from dataclasses import dataclass, field
from enum import StrEnum
from typing import Any, Generic, TypeVar

from typing_extensions import Self
Expand All @@ -26,6 +26,12 @@
WidgetUnion,
)

if sys.version_info >= (3, 11):
from enum import StrEnum
else:
from enum import Enum


T = TypeVar("T")


Expand Down Expand Up @@ -170,7 +176,13 @@ class SubScreenWidgetFormatter(WidgetFormatter[T]):
macros: dict[str, str] = field(default_factory=dict)


class GroupType(StrEnum):
if sys.version_info >= (3, 11):
GroupTypeCls = StrEnum
else:
GroupTypeCls = (str, Enum)


class GroupType(GroupTypeCls):
GROUP = "GROUP"
SCREEN = "SCREEN"

Expand Down

0 comments on commit d93a69c

Please sign in to comment.