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

Module 'mypy_boto3.emr' has no attribute 'Client' #8

Closed
dvirtz opened this issue Dec 11, 2019 · 16 comments
Closed

Module 'mypy_boto3.emr' has no attribute 'Client' #8

dvirtz opened this issue Dec 11, 2019 · 16 comments
Labels
question Further information is requested response-needed Awaiting response from a reporter

Comments

@dvirtz
Copy link

dvirtz commented Dec 11, 2019

executing mypy -c 'from mypy_boto3.emr import Client' produces the error <string>:1: error: Module 'mypy_boto3.emr' has no attribute 'Client'.

It seems that mypy does not support star imports, see python/mypy#4930

This is with Python 3.7.2 and mypy 0.750

@vemel
Copy link
Owner

vemel commented Dec 12, 2019

Thank you for report. Just checked and looks like it is working for me. Make sure you executed python -m mypy_boto3 to build subpackages imports.

# install `pip install boto3-stubs[emr]`

import boto3
from mypy_boto3.emr import Client


def emr_client_example() -> None:
    # equivalent of `boto3.client('s3')`
    client: Client = boto3.client("emr")
    client.cancel_steps("cluster_id", [123])

Mypy output:

examples/emr_example.py:10: error: List item 0 has incompatible type "int"; expected "str"
Found 1 error in 1 file (checked 1 source file)

So, looks like it works for me. Please let me know if it still does not for you.

@dvirtz
Copy link
Author

dvirtz commented Dec 12, 2019

I still get error: Module 'mypy_boto3.emr' has no attribute 'Client'. Which versions are you testing that on?

@vemel
Copy link
Owner

vemel commented Dec 12, 2019

I am testing 1.10.36.0 local build. Okay, so you have mypy-boto3-emr installed. Does this work for you: from mypy_boto3_emr import Client ? If yes - there is something wrong with my index builder.

@vemel vemel added bug Something isn't working response-needed Awaiting response from a reporter question Further information is requested and removed bug Something isn't working labels Dec 12, 2019
@dvirtz
Copy link
Author

dvirtz commented Dec 12, 2019 via email

@vemel
Copy link
Owner

vemel commented Dec 12, 2019

Hmm, then it looks like services index is wrong. could you try python -d mypy_boto3 and then check if from mypy_boto3.emr import Client works?

@dvirtz
Copy link
Author

dvirtz commented Dec 12, 2019

-d is debug output. do you want me to send you that?

@vemel
Copy link
Owner

vemel commented Dec 12, 2019

Sorry, python -m mypy_boto3 of course

@vemel
Copy link
Owner

vemel commented Dec 13, 2019

Any updates? Version 1.10.38.2 should generate index automatically, so you can try it out.

@dvirtz
Copy link
Author

dvirtz commented Dec 16, 2019

With 1.10.38.2 I get <string>:1: error: Module 'mypy_boto3.emr' has no attribute 'Client'; maybe "EMRClient"?

@vemel
Copy link
Owner

vemel commented Dec 16, 2019

Hmm, yes, makes sense, as mypy does not like aliases. Use EMRClient and EMRServiceResource. I decided to change class names to make type resolution and error messages more clear.

@dvirtz
Copy link
Author

dvirtz commented Dec 16, 2019 via email

@vemel vemel closed this as completed Dec 17, 2019
@dvirtz
Copy link
Author

dvirtz commented Dec 17, 2019

Sorry I misled you but the issue is not solved yet. Funny enough, now I get:

mypy -c 'from mypy_boto3.emr import EMRClient'
<string>:1: error: Module 'mypy_boto3.emr' has no attribute 'EMRClient'; maybe "Client"?

and

mypy -c 'from mypy_boto3.emr import Client'
<string>:1: error: Module 'mypy_boto3.emr' has no attribute 'Client'; maybe "EMRClient"?

This is with version 1.10.40.1

@vemel vemel reopened this Dec 18, 2019
@vemel
Copy link
Owner

vemel commented Dec 18, 2019

This is very strange. please try to uninstall boto3-stubs, mypy-boto3 and mypy-boto3-emr packages and install them again with python -m pip install boto3-stubs[emr].

Let me know if it worked.

Also, I try to update to mypy 0.760.

@dvirtz
Copy link
Author

dvirtz commented Dec 18, 2019

Found it. I had no_implicit_reexport = True in my config file and commenting it makes the error go away. Perhaps you want to add everything to __all__ as described in https://mypy.readthedocs.io/en/latest/command_line.html#cmdoption-mypy-no-implicit-reexport

@vemel
Copy link
Owner

vemel commented Dec 18, 2019

Makes sense, will do in the next update. This is because of star imports in generated files, should be done properly.

@vemel
Copy link
Owner

vemel commented Dec 19, 2019

Should be fixed in 1.10.42.1

@vemel vemel closed this as completed Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested response-needed Awaiting response from a reporter
Projects
None yet
Development

No branches or pull requests

2 participants