Reading attributes from aioboto3 object
See original GitHub issueDescribe the bug So one of recent updates started throwing following error:
error: Incompatible types in "await" (actual type "Literal['available', 'deregistered', 'error', 'failed', 'invalid', 'pending', 'transient']", expected type "Awaitable[Any]")
The code in question:
async with session.resource("ec2") as ec2:
image = await ec2.Image(parsed_event.dest_ami)
if await image.state == "pending": <--- this line throws an error
My understanding is that attributes might have been added recently and while this type is correct for boto3, aioboto3 requires to await the property to get the value.
It’s confusing and not well documented, but that’s the only way I made it work. It also makes sense as the object fetches data lazily.
To Reproduce
install types-aioboto3[ec2,organizations,secretsmanager,stepfunctions,lambda,sts] == 9.6.0.post2
install mypy==0.971
Additional context OS X, poetry, boto3==1.21.21
Issue Analytics
- State:
- Created a year ago
- Comments:7
Top Results From Across the Web
aioboto3 - PyPI
Mainly I developed this as I wanted to use the boto3 dynamodb Table object in some async microservices. While all resources in boto3...
Read more >AttributeError: 'ClientCreatorContext' object has no attribute ...
I am trying to use the aioboto3 library to invoke an endpoint on SageMaker asynchronously. Below is the simple python code for that...
Read more >aioboto3/inject.py at main - GitHub
:param Fileobj: A file-like object to upload. At a minimum, it must. implement the `read` method, and must return bytes. :type Bucket: str....
Read more >Async AWS SDK for Python Documentation
Simple example of using aioboto3 to put items into a dynamodb table ... Resource object properties are normally autoloaded, now they are all ......
Read more >class SQS. Client - Boto3 Docs 1.26.36 documentation
If you don't specify the FifoQueue attribute, Amazon SQS creates a ... for the dead-letter queue functionality of the source queue as a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@takeda @johman10 I have just updated all
aiobotocoreservices with the fix included. Please update totypes-aiobotocore-s3/sqs 2.4.0.post1and let me know if it works as it should.Sorry for the delay, my changes look good, so I will release today.