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

(mypy): Python constructs do not implement their interfaces #15651

Closed
rectalogic opened this issue Jul 19, 2021 · 3 comments
Closed

(mypy): Python constructs do not implement their interfaces #15651

rectalogic opened this issue Jul 19, 2021 · 3 comments
Assignees
Labels
bug This issue is a bug. jsii This issue originates in jsii, or this feature must be implemented in jsii. language/python Related to Python bindings needs-reproduction This issue needs reproduction. p1

Comments

@rectalogic
Copy link
Contributor

This was supposed to be fixed in #13474 via jsii, but still occurrs with jsii 1.31.0

Reproduction Steps

Run mypy on this:

#!/usr/bin/env python3

from aws_cdk import (
    App,
    Stack,
    aws_ec2 as ec2,
    aws_ecs as ecs,
    aws_route53 as route53,
    aws_ecs_patterns as ecs_patterns,
)

app = App()
stack = Stack(app, "stack")
vpc = ec2.Vpc(stack, "VPC", cidr="10.0.0.0/16")
sg = ec2.SecurityGroup(
    stack,
    "SG",
    vpc=vpc,
)
zone = route53.HostedZone(
    stack,
    "Zone",
    zone_name="example.com",
    vpcs=[vpc],
)
ecs_patterns.ApplicationLoadBalancedFargateService(
    stack,
    "FGS",
    vpc=vpc,
    security_groups=[sg],
    domain_name="f.example.com",
    domain_zone=zone,
    task_image_options=ecs_patterns.ApplicationLoadBalancedTaskImageOptions(
        image=ecs.ContainerImage.from_registry("foobar"),
        container_name="foobar",
    ),
)

app.synth()

What did you expect to happen?

No errors

What actually happened?

Multiple typing errors:

$ mypy /tmp/m.py
/tmp/m.py:18: error: Argument "vpc" to "SecurityGroup" has incompatible type "Vpc"; expected "IVpc"
/tmp/m.py:18: note: "Vpc" is missing following "IVpc" protocol member:
/tmp/m.py:18: note:     __jsii_proxy_class__
/tmp/m.py:24: error: List item 0 has incompatible type "Vpc"; expected "IVpc"
/tmp/m.py:24: note: "Vpc" is missing following "IVpc" protocol member:
/tmp/m.py:24: note:     __jsii_proxy_class__
/tmp/m.py:29: error: Argument "vpc" to "ApplicationLoadBalancedFargateService" has incompatible type "Vpc"; expected "Optional[IVpc]"
/tmp/m.py:29: note: "Vpc" is missing following "IVpc" protocol member:
/tmp/m.py:29: note:     __jsii_proxy_class__
/tmp/m.py:30: error: List item 0 has incompatible type "SecurityGroup"; expected "ISecurityGroup"
/tmp/m.py:30: note: "SecurityGroup" is missing following "ISecurityGroup" protocol member:
/tmp/m.py:30: note:     __jsii_proxy_class__
/tmp/m.py:32: error: Argument "domain_zone" to "ApplicationLoadBalancedFargateService" has incompatible type "HostedZone"; expected "Optional[IHostedZone]"
/tmp/m.py:32: note: "HostedZone" is missing following "IHostedZone" protocol member:
/tmp/m.py:32: note:     __jsii_proxy_class__
Found 5 errors in 1 file (checked 1 source file)

Environment

  • CDK CLI Version : 2.0.0-rc.11
  • Framework Version: 2.0.0-rc.11
  • Node.js Version: v12.16.2
  • OS : Ubuntu 20.04
  • Language (Version): Python 3.8.10

Other

This was supposed to be fixed in aws/jsii#2809
I am using jsii 1.31.0 which should include this fix.


This is 🐛 Bug Report

@rectalogic rectalogic added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 19, 2021
@peterwoodworth peterwoodworth added the jsii This issue originates in jsii, or this feature must be implemented in jsii. label Jul 20, 2021
@NGL321 NGL321 added language/python Related to Python bindings needs-reproduction This issue needs reproduction. p1 and removed needs-triage This issue or PR still needs to be triaged. labels Jul 24, 2021
@NGL321
Copy link
Contributor

NGL321 commented Jul 24, 2021

Thanks for reporting this @rectalogic!

Since this is a JSII issue, there is a chance it gets tracked on the JSII repo, if you create a ticket there, please reference this one as well 😄

@rectalogic
Copy link
Contributor Author

Just tested with aws-cdk-lib 2.0.0rc27, constructs 10.0.9, jsii 1.41.0 and this is resolved.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. jsii This issue originates in jsii, or this feature must be implemented in jsii. language/python Related to Python bindings needs-reproduction This issue needs reproduction. p1
Projects
None yet
Development

No branches or pull requests

4 participants