@@ -767,23 +767,23 @@ ThenBuildTypes = t.TypeVar("ThenBuildTypes")
767767ElseParsedType = t .TypeVar ("ElseParsedType" )
768768ElseBuildTypes = 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- ]: ...
783783def 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
788788SwitchType = t .TypeVar ("SwitchType" )
789789
0 commit comments