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

IAM: Python type IPrincipal is incompatible with ServicePrincipal #31454

Open
1 task
fraghag opened this issue Sep 16, 2024 · 4 comments
Open
1 task

IAM: Python type IPrincipal is incompatible with ServicePrincipal #31454

fraghag opened this issue Sep 16, 2024 · 4 comments
Labels
@aws-cdk/aws-iam Related to AWS Identity and Access Management bug This issue is a bug. effort/medium Medium work item – several days of effort p3

Comments

@fraghag
Copy link

fraghag commented Sep 16, 2024

Describe the bug

This bug was already reported previously #30431.

Not sure why it was not addressed and the issue closed, so opening a new one.
The AWS plugin in VSCode is quite extensive so it seems to be a very encouraged tool to use for AWS development, but this bug makes the coding experience very poor.

Also the _statement parameter looks very weird

principal = iam.AccountPrincipal("123456789012")
principal.add_to_principal_policy(_statement=iam.PolicyStatement())

and if it's called like that instead of statement like it is in IPrincipal for a reason it's seems like an ugly hack.

If you think that you are doing the correct thing with regards to python typing then we should start a discussion about it with pyright developers.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

I'm expecting to not get typing errors when writing the code as it is intended.

Current Behavior

Raises typing error.

Reproduction Steps

See #30431

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.154.1 (build febce9d)

Framework Version

No response

Node.js Version

v20.12.2

OS

Ubuntu 22.04.4 LTS

Language

Python

Language Version

Python 3.12

Other information

No response

@fraghag fraghag added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 16, 2024
@github-actions github-actions bot added the @aws-cdk/aws-iam Related to AWS Identity and Access Management label Sep 16, 2024
@pahud
Copy link
Contributor

pahud commented Sep 16, 2024

Yes i can produce this error when I install pyright VSCode extension

image

But I won't have that if I install Pylance.

I guess this might be a Pyright bug?

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p3 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Sep 16, 2024
@fraghag
Copy link
Author

fraghag commented Sep 16, 2024

Pylance uses pyright under the hood. But pylance does not highlight typing errors by default, you have to explicitly tell it to in the settings with:

    "python.analysis.typeCheckingMode": "standard",

And also I first checked this with pyright and the guy there says that pyright is doing the right thing and his argument makes sense to me.
microsoft/pyright#8984

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Sep 16, 2024
@gshpychka
Copy link
Contributor

This is not a Pyright bug - in Python, argument names have to match.

This is a limitation of JSII - tracked here: aws/jsii#4541

@xaviergmail
Copy link

This happens with a lot of other interfaces as well, but not all of them for some reason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-iam Related to AWS Identity and Access Management bug This issue is a bug. effort/medium Medium work item – several days of effort p3
Projects
None yet
Development

No branches or pull requests

4 participants