Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Support annotations on transformation functions #1298

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Improvements

- Update Go Helm v3 to use native client. (https://github.com/pulumi/pulumi-kubernetes/pull/1296)
- Python: Allow type annotations on transformation functions. (https://github.com/pulumi/pulumi-kubernetes/pull/1298)

## 2.5.1 (September 2, 2020)

Expand Down
4 changes: 2 additions & 2 deletions provider/pkg/gen/python-templates/yaml/yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import json
import warnings
from copy import copy
from glob import glob
from inspect import getargspec
from inspect import getfullargspec
from typing import Any, Callable, Dict, List, Optional

import pulumi
Expand Down Expand Up @@ -420,7 +420,7 @@ def _parse_yaml_object(
# Allow users to change API objects before any validation.
if transformations is not None:
for t in transformations:
if len(getargspec(t)[0]) == 2:
if len(getfullargspec(t)[0]) == 2:
t(obj, opts)
else:
t(obj)
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/pulumi_kubernetes/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import warnings
from copy import copy
from glob import glob
from inspect import getargspec
from inspect import getfullargspec
from typing import Any, Callable, Dict, List, Optional

import pulumi
Expand Down Expand Up @@ -420,7 +420,7 @@ def _parse_yaml_object(
# Allow users to change API objects before any validation.
if transformations is not None:
for t in transformations:
if len(getargspec(t)[0]) == 2:
if len(getfullargspec(t)[0]) == 2:
t(obj, opts)
else:
t(obj)
Expand Down
4 changes: 3 additions & 1 deletion tests/sdk/python/kustomize/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@

import pulumi_kubernetes as k8s

from typing import Any

ns = k8s.core.v1.Namespace("ns")


def set_namespace(namespace):
def f(obj):
def f(obj: Any):
if "metadata" in obj:
obj["metadata"]["namespace"] = namespace.metadata["name"]
else:
Expand Down