Updated IfThenElse so that it represents the real implementation

This commit is contained in:
Tim Rid 2022-12-23 20:37:05 +01:00
parent ceb4b67ff8
commit 349c8e5dd2

View file

@ -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")