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

(cloudwatch): mypy going crazy around types in cdk >= 2.21.0 #20219

Closed
kornicameister opened this issue May 4, 2022 · 7 comments · Fixed by #20369
Closed

(cloudwatch): mypy going crazy around types in cdk >= 2.21.0 #20219

kornicameister opened this issue May 4, 2022 · 7 comments · Fixed by #20369
Assignees
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@kornicameister
Copy link
Contributor

kornicameister commented May 4, 2022

Describe the bug

monitoring/ses_stack.py: note: In member "__init__" of class "SESStack":
monitoring/ses_stack.py:146:19: error: List item 0 has incompatible type "Metric"; expected "IMetric"  [list-item]
monitoring/ses_stack.py:146:19: note: "Metric" is missing following "IMetric" protocol member:
monitoring/ses_stack.py:146:19: note:     warnings
monitoring/ses_stack.py:150:20: error: List item 0 has incompatible type "Metric"; expected "IMetric"  [list-item]
monitoring/ses_stack.py:150:20: note: "Metric" is missing following "IMetric" protocol member:
monitoring/ses_stack.py:150:20: note:     warnings
monitoring/ses_stack.py:157:19: error: List item 0 has incompatible type "Metric"; expected "IMetric"  [list-item]
monitoring/ses_stack.py:157:19: note: "Metric" is missing following "IMetric" protocol member:
monitoring/ses_stack.py:157:19: note:     warnings
monitoring/ses_stack.py:161:20: error: List item 0 has incompatible type "Metric"; expected "IMetric"  [list-item]
monitoring/ses_stack.py:161:20: note: "Metric" is missing following "IMetric" protocol member:
monitoring/ses_stack.py:161:20: note:     warnings
monitoring/ses_stack.py:168:19: error: List item 0 has incompatible type "Metric"; expected "IMetric"  [list-item]
monitoring/ses_stack.py:168:19: note: "Metric" is missing following "IMetric" protocol member:
monitoring/ses_stack.py:168:19: note:     warnings
monitoring/ses_stack.py:172:20: error: List item 0 has incompatible type "Metric"; expected "IMetric"  [list-item]
monitoring/ses_stack.py:172:20: note: "Metric" is missing following "IMetric" protocol member:
monitoring/ses_stack.py:172:20: note:     warnings
monitoring/ses_stack.py: note: In member "widgets" of class "SESStack":
monitoring/ses_stack.py:182:13: error: List item 0 has incompatible type "Row"; expected "IWidget"  [list-item]
monitoring/ses_stack.py:182:13: note: "Row" is missing following "IWidget" protocol member:
monitoring/ses_stack.py:182:13: note:     warnings
monitoring/ses_stack.py:196:13: error: List item 1 has incompatible type "Row"; expected "IWidget"  [list-item]
monitoring/ses_stack.py:196:13: note: "Row" is missing following "IWidget" protocol member:
monitoring/ses_stack.py:196:13: note:     warnings

Expected Behavior

mypy reports no errors as it was doing in cdk==2.20.0

Current Behavior

Without any changes, code that previously checked out correctly, now throws a bunch of errors around types.

Reproduction Steps

  1. install latest cdk (2.22.0)
  2. install mypy 0.950
  3. run mypy over python sources

Possible Solution

🤷

Additional Information/Context

No response

CDK CLI Version

2.22.0

Framework Version

No response

Node.js Version

14.17.5

OS

MacOs BigSur

Language

Python

Language Version

3.10.1

Other information

No response

@kornicameister kornicameister added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 4, 2022
@github-actions github-actions bot added the @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch label May 4, 2022
@gavllew
Copy link

gavllew commented May 10, 2022

The problem here is that #19825 added a warnings property to the IMetric interface, but failed to add it to the Metric class that implements that interface. This is causing mypy to complain about assignments/parameters that should be valid, as it thinks Metric and IMetric are not compatible.

@kornicameister
Copy link
Contributor Author

kornicameister commented May 16, 2022

@gavllew so the fix is to change type of Metric ti hold warnings? But it doesn't make sense if Metric implements IMetric, right?

kornicameister added a commit to kornicameister/aws-cdk that referenced this issue May 17, 2022
@kornicameister
Copy link
Contributor Author

@gavllew @madeline-k would that #20369 be a proper starting point to fix that?

@gavllew
Copy link

gavllew commented May 17, 2022

@kornicameister Yes, I think that is all that should be necessary.

@kornicameister
Copy link
Contributor Author

That also pops around cw.Row being not compatible with cw.IWidget :/

@kornicameister
Copy link
Contributor Author

@madeline-k @gavllew I changed the type of linked PR to ready to review, awaiting feedback.
I will try to find out what's wrong around cw.Row

@mergify mergify bot closed this as completed in #20369 May 19, 2022
mergify bot pushed a commit that referenced this issue May 19, 2022
Fixes: #20219

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@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.

wphilipw pushed a commit to wphilipw/aws-cdk that referenced this issue May 23, 2022
Fixes: aws#20219

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants