Comments (10)
thank @vemel, let me know if there is anything you need help with ! happy to contribute!
from mypy_boto3_builder.
hi @vemel sorry for the wait. Work been busy. I put out a draft PR at #233
While implmenting, i realised the cloudwatch notification for event bridge has lots of nested structs and different example. Maybe it might be reasonable to use Type.DictStrAny
as you had in your example above.
Also can i check - there are some fields that are enums values, currently i have use type.str - let me know if i using Literal
is preferred. Thanks!
from mypy_boto3_builder.
Hello! Thank you for the feature request.
Unfortunately, botocore
shapes use String
type for Event
shape, so event structure cannot be parsed from botocore
shapes. However, event TypeDef can always be hardcoded manually. I will take a look at how to implement it properly.
from mypy_boto3_builder.
So, it is a tricky change. Events are strings, so this type will not be directly used in any cloudwatch
methods.
Another thing is that there is no way to track if botocore
changes the output format in any way.
Thank you for your participation in the project!
If you want to prepare a pull request:
- Add new TypedDict to typed_dicts.py
CloudwatchEventTypeDef = TypeTypedDict(
"CloudwatchEventTypeDef",
[
TypedDictAttribute("version", Type.str, True),
...
],
)
- add new types to
service_package
inparse_service_package
, somewhere aroundresult.type_defs = result.extract_type_defs()
, use ServiceNameCatalog to check what service you are working with - it makes sense to move
TypeDefSorter(self._get_sortable_type_defs()).sort()
toparse_service_package
.
So end result in parse_service_package
should be smth like
type_defs = self._get_sortable_type_defs()
if service_name == ServiceNameCatalog.cloudwatch:
type_defs.add(CloudwatchEventTypeDef)
# probably we need eventbridge service as well
type_def_sorter = TypeDefSorter(self._get_sortable_type_defs())
result.type_defs = type_def_sorter.sort()
Generate and install package to cross-check:
- generate:
./scripts/build.sh -s cloudwatch --product boto3-services
- install:
./scripts/install.sh cloudwatch
- test on your sample, try to import it
from mypy_boto3_cloudwatch.type_defs import CloudwatchEventTypeDef
Please let me know if you find this helpful or if you are stuck.
from mypy_boto3_builder.
TypedDicts should be something like
CloudwatchEventStateTypeDef = TypeTypedDict(
"CloudwatchEventStateTypeDef",
[
TypedDictAttribute("reason", Type.str, True),
TypedDictAttribute("reasonData", Type.str, True),
TypedDictAttribute("timestamp", Type.str, True),
TypedDictAttribute("value", Type.str, True),
],
)
CloudwatchEventMetricTypeDef = TypeTypedDict(
"CloudwatchEventMetricTypeDef",
[
TypedDictAttribute("id", Type.str, True),
TypedDictAttribute(
"metricStat", Type.DictStrAny, True
), # probably we can improve typing here
TypedDictAttribute("returnData", Type.bool, True),
],
)
CloudwatchEventConfigurationTypeDef = TypeTypedDict(
"CloudwatchEventDetailConfigurationTypeDef",
[
TypedDictAttribute("description", Type.str, True),
TypedDictAttribute("metrics", TypeSubscript(Type.List, [Type.str]), True),
],
)
CloudwatchEventDetailTypeDef = TypeTypedDict(
"CloudwatchEventDetailTypeDef",
[
TypedDictAttribute("alarmName", Type.str, True),
TypedDictAttribute("configuration", CloudwatchEventConfigurationTypeDef, True),
TypedDictAttribute("previousState", CloudwatchEventStateTypeDef, True),
TypedDictAttribute("state", CloudwatchEventStateTypeDef, True),
],
)
CloudwatchEventTypeDef = TypeTypedDict(
"CloudwatchEventTypeDef",
[
TypedDictAttribute("version", Type.str, True),
TypedDictAttribute("id", Type.str, True),
TypedDictAttribute("detail-type", Type.str, True),
TypedDictAttribute("source", Type.str, True),
TypedDictAttribute("account", Type.str, True),
TypedDictAttribute("time", Type.str, True),
TypedDictAttribute("region", Type.str, True),
TypedDictAttribute("resources", TypeSubscript(Type.List, [Type.str]), True),
TypedDictAttribute("detail", CloudwatchEventDetailTypeDef, True),
],
)
from mypy_boto3_builder.
I made some changes toServicePackageParser
, so it is more refactoring-friendly now. Please let me know if you have time for a pull request.
from mypy_boto3_builder.
hi vemel, thanks for the pointers! i will have time for a PR this week - but it looks like you already have the implementation above and i dont want to slow you down.
I can work to improve metricStat
if you want to merge what you already have above.
Or if you dont mind waiting, i should be able to get them out in the next few days.
Thanks!! let me know!
from mypy_boto3_builder.
I definitely do not mind waiting, it is not an urgent change. Take your time.
Once again, if you are stuck - please let me know.
from mypy_boto3_builder.
@xquek Hello! Do you have any updates?
from mypy_boto3_builder.
Thank you for your contribution. I added your TypeDefs to cloudwatch
service stubs. Please let me know if it works for you.
from mypy_boto3_builder.
Related Issues (20)
- upload_fileobj types in S3Client are wrong. HOT 3
- Corrupt tarball for mypy-boto3-ec2 on PyPI HOT 2
- Support configuration of `typing` vs `typing_extensions` HOT 4
- [sts] GetCallerIdentityResponseTypeDef -> Arn should be 'str' but ist dict[str, Any] HOT 3
- GetKeyPolicyResponseTypeDef Policy should be `str` not `Dict[str, Any]` HOT 4
- dynamo: AttributeBase does not include `name` property HOT 2
- Client package ServiceName literal definitions are not necessarily up-to-date HOT 2
- pyright now treats TypedDict field types as invariant instead of covariant resulting in some type checking errors HOT 5
- session.get_credentials() has become optional HOT 2
- ListUserPoolClientsResponseTypeDef : NextToken should be not required HOT 3
- Sub-resources do not inherit correct `.meta.client` type HOT 3
- Misleading return type definition for table.get_item() HOT 2
- S3 ListObjectsV2OutputTypeDef Contents key should be NotRequired HOT 3
- ResponseMetadata attribute being added to EC2 TypeDefs where it doesn't belong HOT 4
- EC2 InstanceTypeDef.Platform Literal incorrectly capitalized HOT 6
- ListObjectVersionsOutputTypeDef CommonPrefixes key can be missing HOT 5
- Output types broken as input types InventoryConfigurationOutputTypeDef, LifecycleRuleOutputTypeDef HOT 5
- Quickstart Failure - Install HOT 3
- type SendMessageBatchRequestEntryQueueTypeDef missing in mypy-boto3-sqs 1.34.101 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mypy_boto3_builder.