Skip to content

Commit 349c8e5

Browse files
committed
Updated IfThenElse so that it represents the real implementation
1 parent ceb4b67 commit 349c8e5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

construct-stubs/core.pyi

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -767,23 +767,23 @@ ThenBuildTypes = t.TypeVar("ThenBuildTypes")
767767
ElseParsedType = t.TypeVar("ElseParsedType")
768768
ElseBuildTypes = t.TypeVar("ElseBuildTypes")
769769

770-
# This does not represent the original code, but it is the only solution that works good with pyright
771-
class _IfThenElse(Construct[ParsedType, BuildTypes]):
770+
class IfThenElse(Construct[ParsedType, BuildTypes]):
772771
condfunc: ConstantOrContextLambda[bool]
773772
thensubcon: Construct[ParsedType, BuildTypes]
774773
elsesubcon: Construct[ParsedType, BuildTypes]
774+
def __new__(
775+
cls,
776+
condfunc: ConstantOrContextLambda[bool],
777+
thensubcon: Construct[ThenParsedType, ThenBuildTypes],
778+
elsesubcon: Construct[ElseParsedType, ElseBuildTypes],
779+
) -> IfThenElse[
780+
t.Union[ThenParsedType, ElseParsedType], t.Union[ThenBuildTypes, ElseBuildTypes]
781+
]: ...
775782

776-
def IfThenElse(
777-
condfunc: ConstantOrContextLambda[bool],
778-
thensubcon: Construct[ThenParsedType, ThenBuildTypes],
779-
elsesubcon: Construct[ElseParsedType, ElseBuildTypes],
780-
) -> _IfThenElse[
781-
t.Union[ThenParsedType, ElseParsedType], t.Union[ThenBuildTypes, ElseBuildTypes]
782-
]: ...
783783
def If(
784784
condfunc: ConstantOrContextLambda[bool],
785785
subcon: Construct[ThenParsedType, ThenBuildTypes],
786-
) -> _IfThenElse[t.Union[ThenParsedType, None], t.Union[ThenBuildTypes, None]]: ...
786+
) -> IfThenElse[t.Union[ThenParsedType, None], t.Union[ThenBuildTypes, None]]: ...
787787

788788
SwitchType = t.TypeVar("SwitchType")
789789

0 commit comments

Comments
 (0)