From c405d09d5f9b696aee80fe88032e05d92b780798 Mon Sep 17 00:00:00 2001 From: Tim Riddermann Date: Thu, 3 Aug 2023 09:21:30 +0200 Subject: [PATCH] fixed error message from `EnumBase` and `FlagsEnumBase` that occures since pyright v1.1.320 --- construct_typed/tenum.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/construct_typed/tenum.py b/construct_typed/tenum.py index a71fb7f..b602f23 100644 --- a/construct_typed/tenum.py +++ b/construct_typed/tenum.py @@ -1,6 +1,8 @@ import enum import typing as t +from typing_extensions import Self + from .generic_wrapper import * @@ -45,7 +47,7 @@ class EnumBase(enum.IntEnum): 'This is the running state.' """ - def __new__(cls, val: t.Union[EnumValue, int]) -> "EnumBase": + def __new__(cls, val: t.Union[EnumValue, int]) -> "Self": if isinstance(val, EnumValue): obj = int.__new__(cls, val.value) obj._value_ = val.value @@ -158,7 +160,7 @@ class FlagsEnumBase(enum.IntFlag): 'This is option two.' """ - def __new__(cls, val: t.Union[EnumValue, int]) -> "FlagsEnumBase": + def __new__(cls, val: t.Union[EnumValue, int]) -> "Self": if isinstance(val, EnumValue): obj = int.__new__(cls, val.value) obj._value_ = val.value