question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reading attributes from aioboto3 object

See original GitHub issue

Describe 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:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
vemelcommented, Sep 27, 2022

@takeda @johman10 I have just updated all aiobotocore services with the fix included. Please update to types-aiobotocore-s3/sqs 2.4.0.post1 and let me know if it works as it should.

2reactions
vemelcommented, Sep 27, 2022

Sorry for the delay, my changes look good, so I will release today.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found