From fa2daec804ae6ca146896ab37b93b6122bbe38a1 Mon Sep 17 00:00:00 2001 From: Tim Rid <6593626+timrid@users.noreply.github.com> Date: Sat, 12 Dec 2020 13:44:28 +0100 Subject: [PATCH] Added stubs for Switch --- construct-stubs/core.pyi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/construct-stubs/core.pyi b/construct-stubs/core.pyi index 3623d1a..c87d02a 100644 --- a/construct-stubs/core.pyi +++ b/construct-stubs/core.pyi @@ -488,6 +488,25 @@ class IfThenElse(t.Generic[ThenParsedType, ThenBuildTypes, ElseParsedType, ElseB def If(condfunc: ConstantOrContextLambda[bool], subcon: Construct[ThenParsedType, ThenBuildTypes]) -> IfThenElse[ThenParsedType, ThenBuildTypes, None, None]: ... +SwitchType = t.TypeVar("SwitchType") + +@t.type_check_only +class _Switch(Construct[ParsedType, BuildTypes]): ... + +@t.overload +def Switch( + keyfunc: ConstantOrContextLambda[SwitchType], + cases: t.Dict[SwitchType, Construct[int, int]], + default: t.Optional[Construct[int, int]] = ... +) -> _Switch[int, int]: ... + +@t.overload +def Switch( + keyfunc: ConstantOrContextLambda[SwitchType], + cases: t.Dict[SwitchType, Construct[t.Any, t.Any]], + default: t.Optional[Construct[t.Any, t.Any]] = ... +) -> _Switch[t.Any, t.Any]: ... + #=============================================================================== # alignment and padding #===============================================================================