-
Notifications
You must be signed in to change notification settings - Fork 245
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
rossetta issue: varargs are ignored when hoisting keyword arguments #1821
Comments
The cluster.add_resource('MyResource', {
"api_version": "v1",
"kind": "Pod",
"metadata": {"name": "mypod"},
"spec": {
"containers": [{
"name": "hello",
"image": "paulbouwer/hello-kubernetes:1.5",
"ports": [{"container_port": 8080}]
}]
}
}) |
@eladb I understand that you closed the issue, but the code snippet is directly from the documentation (see the link in my previous comment). https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_eks.README.html |
Good point. The docs should be fixed. Reopening to track |
The root cause is that auto-generated documentation in Python does not take into account the fact that Related: #826 Transferring to the jsii repo for follow up. |
Thanks for the reassignment @eladb. |
For information, if someone has the same problems, the correct syntax is bellow.
cluster.add_resource('MyResource', {
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name": "mypod"},
"spec": {
"containers": [{
"name": "hello",
"image": "paulbouwer/hello-kubernetes:1.5",
"ports": [{"container_port": 8080}]
}]
}
}) |
The original type signature is the following: addResource(id: string, ...manifest: any[]): KubernetesResource This particular example was generated without compilation, so it did not have access to the type information during transliteration. The first thing we should attempt is trying to make the original version compilable and see whether this fixes it. |
When processing function calls, the signature of the function was not considered when it was available, and an object literal used as the final argument of a variadic call would be rendered as keyword arguments when this is actually not a correct way to render variadic values. This change attempts to read the resolved signature of the function beging called, in order to correctly render variadic values. Fixes #1821
Turns out even with type information the "bad" code would be generated in this case... I've submitted a PR to address that. |
When processing function calls, the signature of the function was not considered when it was available, and an object literal used as the final argument of a variadic call would be rendered as keyword arguments when this is actually not a correct way to render variadic values. This change attempts to read the resolved signature of the function beging called, in order to correctly render variadic values. Fixes #1821 --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
Note - in order for the documentation to actually be fixed, the example code must be made compilable (otherwise the type information needed to determine the call is variadic will not be available). This can be achieved by dropping a The necessary fix will be available in |
This is actually fixed in aws/aws-cdk@3c116f3 where I inadvertently committed a fixture... |
Original title: cluster.add_resource got an unexpected keyword argument 'api_version'
Using
Python
when I try to add a resource using the example available here I have an error during the execution.The error is :
Reproduction Steps
Create a stack with this
and run
cdk synth
.Error Log
Environment
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: