mirror of https://github.com/pulumi/pulumi.git
05574aaaa4
Epic: Improved Typing https://github.com/pulumi/pulumi/issues/12689 This PR adds the flag `Languages.Python.InputTypes` to the schema, which can take the values `classes` or `classes-and-dicts`. In the first iteration of the feature, this defaults to `classes`, which leaves code generation as is and does not change input types.. If the flag is set to `classes-and-dicts`, `TypedDict` based types are generated next to the current `<Type>Args` classes. In the future this could be extended to support `dicts` to generate only `TypedDict` types. The generated types are conditional on the used type checker to work around perf issues in MyPy and PyCharm, see https://github.com/pulumi/pulumi/issues/12689#issuecomment-2117240276 ```python if not MYPY: class DeploymentArgsDict(TypedDict): api_version: NotRequired[Input[str]] kind: NotRequired[Input[str]] metadata: NotRequired[Input['ObjectMetaArgsDict']] ... elif False: DeploymentArgsDict: TypeAlias = Mapping[str, Any] ``` Removing the workaround is tracked in https://github.com/pulumi/pulumi/issues/16408 --------- Co-authored-by: Anthony King <anthony@datapane.com> Co-authored-by: Justin Van Patten <jvp@justinvp.com> |
||
---|---|---|
.. | ||
host.go |