Skip to content

Add boto3 and botocore legacy stubs #10615

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

vemel
Copy link

@vemel vemel commented Jun 10, 2021

Description

Adds types-botocore and types-boto3 stub packages for botocore and boto3 respectively.

These type annotations are built automatically with mypy_boto3_builder and updated on a new boto3/botocore release.

This is a great idea to install missing type annotations with mypy, thank you!

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 10, 2021

Thanks for the PR! This seems like a good idea.

However, we are still figuring out the best way to suggest stubs from outside of typeshed (see #10619). If/when we decide on how to deal with adding suggested stubs generally, we can add boto3 and botocore stubs to suggestions.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

prefect (https://github.com/PrefectHQ/prefect.git)
+ src/prefect/engine/results/s3_result.py:7: error: Library stubs not installed for "boto3" (or incompatible with Python 3.8)
+ src/prefect/engine/results/s3_result.py:76: error: Library stubs not installed for "botocore.exceptions" (or incompatible with Python 3.8)
+ src/prefect/engine/results/s3_result.py:139: error: Library stubs not installed for "botocore" (or incompatible with Python 3.8)
+ src/prefect/storage/s3.py:157: error: Library stubs not installed for "botocore.exceptions" (or incompatible with Python 3.8)
+ src/prefect/environments/execution/fargate/fargate_task.py:386: error: Library stubs not installed for "boto3" (or incompatible with Python 3.8)
+ src/prefect/environments/execution/fargate/fargate_task.py:387: error: Library stubs not installed for "botocore.exceptions" (or incompatible with Python 3.8)
+ src/prefect/agent/fargate/agent.py:145: error: Library stubs not installed for "boto3" (or incompatible with Python 3.8)
+ src/prefect/agent/fargate/agent.py:145: note: Hint: "python3 -m pip install types-boto3"
+ src/prefect/agent/fargate/agent.py:147: error: Library stubs not installed for "botocore.config" (or incompatible with Python 3.8)
+ src/prefect/agent/fargate/agent.py:229: error: Library stubs not installed for "botocore.exceptions" (or incompatible with Python 3.8)
+ src/prefect/agent/ecs/agent.py:167: error: Library stubs not installed for "botocore.config" (or incompatible with Python 3.8)
+ src/prefect/agent/ecs/agent.py:167: note: Hint: "python3 -m pip install types-botocore"
+ src/prefect/utilities/aws.py:10: error: Library stubs not installed for "boto3" (or incompatible with Python 3.8)
+ src/prefect/utilities/aws.py:14: error: Library stubs not installed for "botocore" (or incompatible with Python 3.8)
+ src/prefect/utilities/aws.py:14: error: Library stubs not installed for "botocore.client" (or incompatible with Python 3.8)

core (https://github.com/home-assistant/core.git)
+ homeassistant/components/route53/__init__.py:7: error: Library stubs not installed for "boto3" (or incompatible with Python 3.8)  [import]
+ homeassistant/components/amazon_polly/tts.py:7: error: Library stubs not installed for "boto3" (or incompatible with Python 3.8)  [import]
+ homeassistant/components/amazon_polly/tts.py:7: note: Hint: "python3 -m pip install types-boto3"
+ homeassistant/components/amazon_polly/tts.py:8: error: Library stubs not installed for "botocore" (or incompatible with Python 3.8)  [import]
+ homeassistant/components/amazon_polly/tts.py:8: note: Hint: "python3 -m pip install types-botocore"

dragonchain (https://github.com/dragonchain/dragonchain.git)
+ dragonchain/lib/interfaces/aws/sns.py:20:1: error: Library stubs not installed for "boto3" (or incompatible with Python 3.8)
+ dragonchain/lib/interfaces/aws/ecr.py:21:1: error: Library stubs not installed for "boto3" (or incompatible with Python 3.8)
+ dragonchain/lib/interfaces/aws/ecr.py:21:1: note: Hint: "python3 -m pip install types-boto3"
+ dragonchain/lib/interfaces/aws/s3.py:21:1: error: Library stubs not installed for "boto3" (or incompatible with Python 3.8)
+ dragonchain/lib/interfaces/aws/s3.py:22:1: error: Library stubs not installed for "botocore" (or incompatible with Python 3.8)
+ dragonchain/lib/interfaces/aws/s3.py:22:1: note: Hint: "python3 -m pip install types-botocore"
+ dragonchain/lib/interfaces/aws/s3_utest.py:21:1: error: Library stubs not installed for "botocore" (or incompatible with Python 3.8)
- dragonchain/job_processor/contract_job_utest.py:454:9: error: Cannot assign to a method
- dragonchain/job_processor/contract_job_utest.py:455:9: error: Cannot assign to a method
- dragonchain/job_processor/contract_job_utest.py:456:9: error: Cannot assign to a method
- dragonchain/job_processor/contract_job_utest.py:458:9: error: Cannot assign to a method
- dragonchain/job_processor/contract_job_utest.py:459:9: error: Cannot assign to a method
- dragonchain/job_processor/contract_job_utest.py:465:9: error: Cannot assign to a method
- dragonchain/job_processor/contract_job_utest.py:466:9: error: Cannot assign to a method
- dragonchain/job_processor/contract_job_utest.py:467:468: note: (Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)
+ dragonchain/job_processor/contract_job_utest.py:454:455: note: (Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)

scrapy (https://github.com/scrapy/scrapy.git)
+ scrapy/utils/boto.py:21: error: Library stubs not installed for "botocore" (or incompatible with Python 3.8)
- scrapy/utils/versions.py:4: note: (or run "mypy --install-types" to install all missing stub packages)
+ scrapy/extensions/feedexport.py:131: error: Library stubs not installed for "botocore" (or incompatible with Python 3.8)
+ scrapy/extensions/feedexport.py:131: error: Library stubs not installed for "botocore.session" (or incompatible with Python 3.8)
+ scrapy/pipelines/files.py:95: error: Library stubs not installed for "botocore" (or incompatible with Python 3.8)
+ scrapy/pipelines/files.py:95: error: Library stubs not installed for "botocore.session" (or incompatible with Python 3.8)
+ scrapy/core/downloader/handlers/s3.py:33: error: Library stubs not installed for "botocore" (or incompatible with Python 3.8)
+ scrapy/core/downloader/handlers/s3.py:33: error: Library stubs not installed for "botocore.auth" (or incompatible with Python 3.8)
+ scrapy/core/downloader/handlers/s3.py:33: note: (or run "mypy --install-types" to install all missing stub packages)
+ scrapy/core/downloader/handlers/s3.py:33: note: Hint: "python3 -m pip install types-botocore"
- scrapy/utils/versions.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
+ scrapy/core/downloader/handlers/s3.py:33: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
+ scrapy/core/downloader/handlers/s3.py:34: error: Library stubs not installed for "botocore.credentials" (or incompatible with Python 3.8)
+ scrapy/core/downloader/handlers/s3.py:63: error: Library stubs not installed for "botocore.awsrequest" (or incompatible with Python 3.8)
+ tests/test_feedexport.py:284: error: Library stubs not installed for "botocore.stub" (or incompatible with Python 3.8)

paasta (https://github.com/yelp/paasta.git)
+ paasta_tools/kubernetes/bin/paasta_cleanup_stale_nodes.py:32: error: Library stubs not installed for "boto3" (or incompatible with Python 3.7)
+ paasta_tools/kubernetes/bin/paasta_cleanup_stale_nodes.py:34: error: Library stubs not installed for "botocore.exceptions" (or incompatible with Python 3.7)
+ paasta_tools/kubernetes/bin/paasta_cleanup_stale_nodes.py:34: note: Hint: "python3 -m pip install types-botocore"
+ paasta_tools/paasta_remote_run.py:30: error: Library stubs not installed for "boto3.session" (or incompatible with Python 3.7)
+ paasta_tools/cli/cmds/spark_run.py:17: error: Library stubs not installed for "boto3.exceptions" (or incompatible with Python 3.7)
+ paasta_tools/cli/cmds/spark_run.py:17: note: Hint: "python3 -m pip install types-boto3"

pandas (https://github.com/pandas-dev/pandas.git)
+ pandas/io/common.py:343: error: Library stubs not installed for "botocore.exceptions" (or incompatible with Python 3.8)  [import]
+ pandas/io/common.py:343: note: Hint: "python3 -m pip install types-botocore"
+ pandas/tests/io/conftest.py:111: error: Library stubs not installed for "boto3" (or incompatible with Python 3.8)  [import]
+ pandas/tests/io/conftest.py:111: note: Hint: "python3 -m pip install types-boto3"
+ pandas/tests/io/test_s3.py:16: error: Library stubs not installed for "botocore.response" (or incompatible with Python 3.8)  [import]
+ pandas/tests/io/parser/test_network.py:219: error: Library stubs not installed for "botocore" (or incompatible with Python 3.8)  [import]

@vemel
Copy link
Author

vemel commented Jun 10, 2021

@JukkaL thank you for a quick response! Probably, mypy can suggest to install types-<library> or <library>-stubs automatically if they exist in PyPI and have Typing :: Typed classifier.

I am not sure if it should be done on a regular mypy run, probably only with --install-types flag.

I will keep the PR open for now.

@JelleZijlstra
Copy link
Member

@vemel that's too risky because anyone can upload things to PyPI, and installing packages can execute arbitrary code. In addition, low-quality stubs packages can lead to more problems than they solve. We need some sort of vetting.

@vemel
Copy link
Author

vemel commented Feb 21, 2022

Hello!

Any update on this?

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

Successfully merging this pull request may close these issues.

3 participants