youtype / mypy_boto3_builder

Type annotations builder for boto3 compatible with VSCode, PyCharm, Emacs, Sublime Text, pyright and mypy.
https://youtype.github.io/mypy_boto3_builder/
MIT License
544 stars 36 forks source link

Add CW event bridge notification types #233

Closed xquek closed 10 months ago

xquek commented 11 months ago

Notes

I base my types using examples from

In cloudwatch-and-eventbridge.html, there are several different event types (or detail-type). I was wondering do we need to create different type def for different event. (detail-type)

I am also not sure how accurate the examples are - if you know of a better source for reference, do let me know!

I havent add any UT, let. me know what i should add.

Type of change

Checklist

All of these are optional:

Thank you!

vemel commented 11 months ago

Thank you for your contribution!

Looks good to me. Please test how it works and move PR to ready for review once tested.

Let me know if you need any help with testing.

xquek commented 11 months ago

Thanks @vemel, what are your recommended steps for testing? do i write tests for it or it is more of a manual testing?

vemel commented 11 months ago

I do not think we need automated tests, so manual testing is enough.

  1. As far as I can see, your code does not add TypeDefs to CloudWatch service package. Please add this logic.

Find type_defs = result.get_type_defs() line in mypy_boto3_builder/parsers/service_package_parser.py. This is where you want to add your new type annotations.

from mypy_boto3_builder.service_name import ServiceNameCatalog

...

type_defs = result.get_type_defs()

# Add hardcoded CloudwatchEvent type definitions to cloudwatch service
if self.service_name == ServiceNameCatalog.cloudwatch:
   type_defs.add(CloudwatchEventTypeDef)
  1. Build and install mypy-boto3-cloudwatch
poetry shell

# generate ./mypy_boto3_output/mypy_boto3_cloudwatch_package
./scripts/build.sh -s cloudwatch--product boto3-service

#  install generated `mypy-boto3-cloudwatch`
./scripts/install.sh cloudwatch
  1. Write and run a code sample to check your changes work. Create test.py in project root with this contents
from mypy_boto3_cloudwatch.type_defs import CloudwatchEventTypeDef, CloudwatchEventMetricStatsMetricTypeDef 

# checking that event is type checked correctly
my_event: CloudwatchEventTypeDef = {...}

# checking that underlying TypeDefs were also added to `mypy_boto3_cloudwatch`
metric_stats: CloudwatchEventMetricStatsMetricTypeDef = {...}

Run pyright test.py or mypy test.py and check if it verifies types correctly.

vemel commented 11 months ago

@xquek please let me know if you have time to finish this PR. If not - I can merge it as it is and do the rest.

xquek commented 11 months ago

Hi @vemel, apologies havent had the time to work on it this week yet. i think it might be faster for you to merge it and complete it - sorry about that

vemel commented 10 months ago

No worries. Thank you a lot for your contribution 🥇

Please undraft the PR once you stop working on it.

xquek commented 10 months ago

Done! And thank you,!