Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Cannot access member "client" for type "ClientMeta" #16

Open
icaroHenrique opened this issue Jan 27, 2021 · 2 comments
Open

Error Cannot access member "client" for type "ClientMeta" #16

icaroHenrique opened this issue Jan 27, 2021 · 2 comments

Comments

@icaroHenrique
Copy link

Hi!

I'm using botostubs to facilitate learning in the boto3 API.

While using it, I tested a code provided by the boto3 documentation itself and had the following error:

image

Any attempt to use exceptions with s3 botostubs fails.

Am I doing something wrong?

Here is the code:

import boto3
import botostubs

s3 = boto3.client('s3') #type: botostubs.S3
try:
    s3.create_bucket(Bucket='sdkpython')
except s3.meta.client.exceptions.BucketAlreadyExists as err:
    print("Bucket already exists!".format(err.response['Error']['Bucket']))
    raise err

Thanks!

@jeshan
Copy link
Owner

jeshan commented Jan 29, 2021

Thanks for reporting this and being a botostubs user.
You probably did it right but I think you'd get the problem without botostubs. Can you confirm that for me?
This is because exceptions, like most classes, are runtime classes in boto3

Still, it may still be addressable in botostubs. I'll see if I can work on this tonight otherwise it will have to wait.

@icaroHenrique
Copy link
Author

Hello!

Thank you for your help!

I got the code exactly as in the boto3 documentation (https://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.html)

I did two tests. The first has a bucket name exists and the other does not.
Follow the prints and the code at the end.

First test:
image

Second test:
image

import boto3
import botostubs

client = boto3.client('s3') #type: botostubs.S3

try:
    client.create_bucket(Bucket='icaroaws')

except client.meta.client.exceptions.BucketAlreadyExists as err:
    print("Bucket {} already exists!".format(err.response['Error']['BucketName']))
    raise err

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants