From 349c8e5dd214c4e1bbdf027a3bf995d7b483dde3 Mon Sep 17 00:00:00 2001 From: Tim Rid <6593626+timrid@users.noreply.github.com> Date: Fri, 23 Dec 2022 20:37:05 +0100 Subject: [PATCH] Updated IfThenElse so that it represents the real implementation --- construct-stubs/core.pyi | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/construct-stubs/core.pyi b/construct-stubs/core.pyi index 7e6dfd1..32b4b77 100644 --- a/construct-stubs/core.pyi +++ b/construct-stubs/core.pyi @@ -767,23 +767,23 @@ ThenBuildTypes = t.TypeVar("ThenBuildTypes") ElseParsedType = t.TypeVar("ElseParsedType") ElseBuildTypes = t.TypeVar("ElseBuildTypes") -# This does not represent the original code, but it is the only solution that works good with pyright -class _IfThenElse(Construct[ParsedType, BuildTypes]): +class IfThenElse(Construct[ParsedType, BuildTypes]): condfunc: ConstantOrContextLambda[bool] thensubcon: Construct[ParsedType, BuildTypes] elsesubcon: Construct[ParsedType, BuildTypes] + def __new__( + cls, + condfunc: ConstantOrContextLambda[bool], + thensubcon: Construct[ThenParsedType, ThenBuildTypes], + elsesubcon: Construct[ElseParsedType, ElseBuildTypes], + ) -> IfThenElse[ + t.Union[ThenParsedType, ElseParsedType], t.Union[ThenBuildTypes, ElseBuildTypes] + ]: ... -def IfThenElse( - condfunc: ConstantOrContextLambda[bool], - thensubcon: Construct[ThenParsedType, ThenBuildTypes], - elsesubcon: Construct[ElseParsedType, ElseBuildTypes], -) -> _IfThenElse[ - t.Union[ThenParsedType, ElseParsedType], t.Union[ThenBuildTypes, ElseBuildTypes] -]: ... def If( condfunc: ConstantOrContextLambda[bool], subcon: Construct[ThenParsedType, ThenBuildTypes], -) -> _IfThenElse[t.Union[ThenParsedType, None], t.Union[ThenBuildTypes, None]]: ... +) -> IfThenElse[t.Union[ThenParsedType, None], t.Union[ThenBuildTypes, None]]: ... SwitchType = t.TypeVar("SwitchType")