From 1ce73a520cc3b68a8a37dee3ea0b974a95699b7f Mon Sep 17 00:00:00 2001 From: Jack Cherng Date: Sun, 21 Apr 2024 03:59:42 +0800 Subject: [PATCH] refactor: naive functional StrEnum polyfill Signed-off-by: Jack Cherng --- plugin/core/typing.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugin/core/typing.py b/plugin/core/typing.py index 0fc98b923..f4754b829 100644 --- a/plugin/core/typing.py +++ b/plugin/core/typing.py @@ -38,8 +38,15 @@ else: _T = TypeVar("_T") - class StrEnum(Type): # type: ignore - pass + class StrEnum(str, Enum): + """ + Naive polyfill for Python 3.11's StrEnum. + + See https://docs.python.org/3.11/library/enum.html#enum.StrEnum + """ + + __format__ = str.__format__ + __str__ = str.__str__ class NotRequired(Type, Generic[_T]): # type: ignore pass