-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
(ec2): Subnet and ISubnet variable naming causes Pylance type error #20125
Comments
@jakestambaugh I was not able to reproduce this issue. I created a new project with npx cdk init --language=python app I then opened VSCode and installed the Is there anything else about your setup that could be causing the issue? |
I think that I installed Pylance as a dependency of the "Python" package (https://marketplace.visualstudio.com/items?itemName=ms-python.python). It could be that the default Pylance extension settings don't configure linting. FWIW, I was able to reproduce this on a fresh Ubuntu installation with the Python extension. If you want to add this to the {
"recommendations": [
"ms-python.python"
]
} |
This happens in a lot of constructs and is being tracked here: aws/jsii#4541 and aws/jsii#2927 |
Are there any workarounds available? Like muting pyright warnings etc. The issues from previous comment are more than one year old :) Just wondering how people work with python CDK. |
yes, the current workaround is to use typing.cast to satisfy the type checker. |
Closing this as a duplicate of aws/jsii#4541 track there for updates/comments. |
|
Describe the bug
The L2 construct
Subnet
doesn't use the same method parameter names asISubnet
inassociate_network_acl
. This makes Pylance believe thatSubnet
does not implement the interfaceISubnet
, causing it to raise warnings.Expected Behavior
Pylance would understand that "Subnet" implements "ISubnet" and not raise errors.
Current Behavior
Reproduction Steps
In VS Code with the "Pylance" language server extension enabled, add this stack to a CDK project and look for the red squiggly lines in the
SubnetSelection
constructor.Possible Solution
Change the parameter name for the
INetworkAcl
type to be consistent acrossSubnet
andISubnet
.aws-cdk/packages/@aws-cdk/aws-ec2/lib/vpc.ts
Line 61 in f199fad
aws-cdk/packages/@aws-cdk/aws-ec2/lib/vpc.ts
Line 1757 in f199fad
Additional Information/Context
No response
CDK CLI Version
2.22.0 (build 1db4b16)
Framework Version
Pylance v2022.4.3
Node.js Version
v16.14.2
OS
Ubuntu 20.04.4 LTS (WSL 2)
Language
Python
Language Version
3.10.4
Other information
No response
The text was updated successfully, but these errors were encountered: