From 93784742399f1a7882c1539255f2e8cc64864ef5 Mon Sep 17 00:00:00 2001 From: Jack Cherng Date: Sun, 21 Apr 2024 03:46:45 +0800 Subject: [PATCH] fixup: try to fix NotRequired, Required, TypeGuard Signed-off-by: Jack Cherng --- plugin/core/typing.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugin/core/typing.py b/plugin/core/typing.py index 5a3b23511..6bae0df89 100644 --- a/plugin/core/typing.py +++ b/plugin/core/typing.py @@ -27,6 +27,8 @@ final, # noqa: F401 ) + + if sys.version_info >= (3, 11): from enum import StrEnum # noqa: F401 from typing import ( @@ -36,11 +38,12 @@ TypeGuard, # noqa: F401 ) else: + _T = TypeVar("_T") class StrEnum(Type): # type: ignore pass - class NotRequired(Type): # type: ignore + class NotRequired(Generic[_T]): # type: ignore pass class ParamSpec(Type): # type: ignore @@ -50,8 +53,8 @@ class ParamSpec(Type): # type: ignore def __init__(*args, **kwargs) -> None: # type: ignore pass - class Required(Type): # type: ignore + class Required(Generic[_T]): # type: ignore pass - class TypeGuard(Type): # type: ignore + class TypeGuard(Generic[_T]): # type: ignore pass