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)
- Incorrectly typed `aioboto.dynamodb.BatchWriter` HOT 10
- Missing `total=False` on some TypedDict with boto3-stubs>=1.28.3 HOT 7
- `InstanceTypeDef` gone in `mypy-boto3-ec2==1.28.3.post1` HOT 5
- "TypeError: duplicate base class object" for types-aiobotocore-dynamodb version 2.5.2.post1 HOT 3
- Mypy-boto3-appflow 1.28.12 has inconsistent typing HOT 15
- Regression boto3-stubs[dynamodb] Table.get_item typing HOT 4
- Wrong types for IAMClient.get_policy_version HOT 2
- Shorten package descriptions for compatibility with Azure DevOps mirroring, pipelines HOT 3
- Return type incorrect for DynamoDb Client methods HOT 2
- The query paginator returns unexpected Type QueryOutputTableTypeDef HOT 2
- 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
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.