Commit Graph

19 Commits

Author SHA1 Message Date
Julien ca60d337e2
Generate TypedDict input types by default ()
With https://github.com/pulumi/pulumi/pull/15957 we introduced the
schema setting `Languages.Python.InputTypes` to optionally generate
TypedDict based input types side-by-side with Args classes. This setting
defaulted to `classes`, meaning that only Args classes are generated. To
enable the TypedDict types, SDK authors had to explicitly opt in by
setting it to `classes-and-dicts`.

We now flip this setting to generating TypedDict input types
side-by-side with the Args classes, unless explicitly disabled by
setting it to `classes`.

Fixes https://github.com/pulumi/pulumi/issues/16375
2024-07-23 11:26:54 +00:00
Julien P 05574aaaa4
Generate TypedDicts for python inputs ()
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>
2024-06-18 15:24:42 +00:00
Robbie McKinstry 0ee99fcc6f
Add Pyproject schema.
This commit adds the pyproject.toml schema in Go,
and provides a hook to marshal the data in codegen.
Lastly, it adds a toggle to the provider schema to
enable pyproject.toml generation.
2023-05-27 13:18:27 -04:00
Ian Wahbe f2d8858444
Respect schema versions (toggled via flag) ()
* Add version (when env var is set)

* Correct python pypi implementation

* Add a test

* Update CHANGELOG_PENDING.md

* Set as language option

* Remove version.txt from .gitignore

* Add go support

* Correctly handle nodejs.pluginVersion
2022-02-03 17:07:13 +01:00
Ian Wahbe eb735c7106
[codegen/python] emit `pulumiplugin.json` by default ()
* Emit pulumiplugin.json unconditionally

* Update tests

* Update CHANGELOG_PENDING.md

* Add newline to end of pulumiplugin.json
2021-12-01 18:07:23 -08:00
Ben Schiborr df61004e3f
Ability to require minimum Python version ()
Co-authored-by: Komal <komalsali@gmail.com>
Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2021-10-26 14:33:21 -07:00
Justin Van Patten 230f4ee006
Support "lifting" single-valued method returns to their return type ()
This change allows lifting single valued method returns rather than using an output structure.
2021-10-01 11:33:02 -07:00
James Nugent 73c8cc3ec5
Permit override of Python package naming ()
This commit adds a new language option for Python generation to specify
the package name instead of using `pulumi_x` where x is the name defined
in the schema.

A new test is added, and this has also been shown to produce no diff
when run against `pulumi-eks`.
2021-05-06 11:18:14 -07:00
Pat Gavlin 1cc084dc0e
Fix inconsistent object type naming. ()
See  for a complete description of the issue. In short, we generate
inconsistent names for object types depending on whether or not they are
transitively reachable from resources or functions, which risks
unintentional breaking changes due to schema updates.

1. Name "input" types differently: `TArgs` for a type that is used in
   resource inputs, having `Input<T>` properties, and `T` for a type
   that is used in invoke inputs. The same schema type can produce both.

2. Always keep the name `T` for output types, avoid appending `Result` to
   the name.

3. As needed, introduce a flag in the existing providers' schemas to avoid
   breaking changes. Consider removing it on a major version bump.

Fixes .
2021-04-15 19:03:28 -07:00
pulumi-bot 73a66f48ea [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
Justin Van Patten 5ab051cd97
Implement GetRequiredPlugins for Python ()
Implement GetRequiredPlugins for Python, which determines the plugins
required by the program.

Also, if the `virtualenv` runtime option is set, and the specified
virtual directory is missing or empty, automatically create it and
install dependencies into it.
2020-12-03 19:22:16 -08:00
Komal 995d3b9b6c
Remove UsesIOClasses check. () 2020-11-24 19:15:37 -06:00
Justin Van Patten 5164725cb5
[codegen/python] Remove panic from PyName ()
The codegen updates have been run against all providers, so there's no longer a need to keep the panic.
2020-09-14 08:42:01 -07:00
Albert Zhong 69c57f8b47
Add ignorePyNamePanic python flag () 2020-09-02 16:25:19 -07:00
Komal ff219a2381
Use input/output classes in program gen () 2020-08-06 15:09:23 -07:00
Komal d699627ff6
[codegen/python] Fix k8s __init__.py generation ()
* Fix k8s __init__.py generation

* Add comment for regex
2020-06-10 13:55:10 -07:00
Komal 238adf2f2f
[codegen/python] Allow import path overrides ()
* Allow import path overrides

* Fix typo

* Rename ModuleToPackage to ModuleNameOverrides
2020-06-09 14:33:02 -07:00
Komal b93259c6bb
[codegen/python] Fix readme generation ()
* Fix readme generation

* Allow readme text to be passed in with the package.
2020-06-08 13:07:56 -07:00
Pat Gavlin 1f19cbbe08
Clean up the language-specific schema APIs. ()
Rather than forcing consumers to deal with language-specific data
ad-hoc, add an API that allows all language-specific data to be decoded
up-front.
2020-04-20 16:36:05 -07:00