more switch fixes
Some checks are pending
CI / OS ubuntu-latest, Python 3.10 (push) Waiting to run
CI / OS ubuntu-latest, Python 3.11 (push) Waiting to run
CI / OS ubuntu-latest, Python 3.12 (push) Waiting to run
CI / OS ubuntu-latest, Python 3.13 (push) Waiting to run
CI / OS ubuntu-latest, Python 3.9 (push) Waiting to run
CI / OS windows-latest, Python 3.10 (push) Waiting to run
CI / OS windows-latest, Python 3.11 (push) Waiting to run
CI / OS windows-latest, Python 3.12 (push) Waiting to run
CI / OS windows-latest, Python 3.13 (push) Waiting to run
CI / OS windows-latest, Python 3.9 (push) Waiting to run
CI / create_wheel_and_sdist (push) Waiting to run

This commit is contained in:
wrapper 2026-04-07 19:02:24 +07:00
parent 0c93e4d551
commit 2f078b340b
2 changed files with 6 additions and 3 deletions

View file

@ -4,6 +4,7 @@ This modification features:
- **ConstantOrContextLambda2 type**
- **Typing for Subconstruct**
- **Type hint for Computed**
- **Switch typing fixes**
The original README.md file was described down below:
# construct-typing

View file

@ -802,6 +802,8 @@ def If(
SwitchType = t.TypeVar("SwitchType")
SwitchParsedType = t.TypeVar("SwitchParsedType")
SwitchBuildTypes = t.TypeVar("SwitchBuildTypes")
SwitchDefaultParsedType = t.TypeVar("SwitchDefaultParsedType")
SwitchDefaultBuildTypes = t.TypeVar("SwitchDefaultBuildTypes")
class Switch(Construct[ParsedType, BuildTypes]):
keyfunc: ConstantOrContextLambda[t.Any]
@ -816,11 +818,11 @@ class Switch(Construct[ParsedType, BuildTypes]):
) -> Switch[SwitchParsedType | None, SwitchBuildTypes | None]: ...
@t.overload
def __new__(
cls: "type[Switch[SwitchParsedType, SwitchBuildTypes]]",
cls: "type[Switch[SwitchParsedType | SwitchDefaultParsedType, SwitchBuildTypes | SwitchDefaultBuildTypes]]",
keyfunc: ConstantOrContextLambda[SwitchType],
cases: dict[t.Any, Construct[SwitchParsedType, SwitchBuildTypes]],
default: Construct[SwitchParsedType, SwitchBuildTypes],
) -> Switch[SwitchParsedType, SwitchBuildTypes]: ...
default: Construct[SwitchDefaultParsedType, SwitchDefaultBuildTypes],
) -> Switch[SwitchParsedType | SwitchDefaultParsedType, SwitchBuildTypes | SwitchDefaultBuildTypes]: ...
# @t.overload
# def __new__(
# cls: "type[Switch[t.Any, t.Any]]",