Skip to main content

Facilitates using beartype runtime type-checking with the AWS SDK

Project description

bearboto3

GitHub Workflow Status GitHub Workflow Status PyPI - Downloads PyPI - Python Version

This project provides support for using the boto3 library (AWS Python SDK) and associated stub libraries such as boto3-stubs together with beartype for runtime type-checking.

Since boto3 uses a data-driven factory model to create class types at runtime, you cannot annotate them without support of stub libraries such as boto3-stubs. However, if you are using a runtime type-checker such as beartype, type validation will fail since the types technically do not match (even though they represent the same object schema).

Behold...

this project makes use of the typing.TYPE_CHECKING constant found in the python typing module to conditionally load either static types from a stub library (in this case boto3-stubs), or custom annotated types that can be checked with beartype.

Installation/Use

See the list of services to see what is currently implemented.

Supported python versions:

  • >= 3.7

Install with pip:

pip3 install bearboto3

or with whatever dependency management tool you use (like poetry):

poetry add bearboto3

Then in your code, import the specific types you need:

from beartype import beartype
from bearboto3.s3 import S3Client, Bucket
import boto3

@beartype
def example(s3: S3Client) -> Bucket:
    return s3.create_bucket(Bucket='mybucket')

s3_client = boto3.client('s3')
bucket = example(s3_client)

You will be able to have your salmon and eat it too!

Installing the type stubs

At present, there does not appear to be a way in pyproject.toml to specify extra/optional packages that should be installed as dev dependencies. The type stubs for each service (which allow for IDE integration courtsey of boto3-stubs) can be installed as extras such as:

poetry install bearboto3[s3]

but NOTE this will install the type stubs as runtime dependencies given the limitations above. The type stub libraries are not needed to run any code you use this package with, so the recommended approach is to install whatever type stubs you need yourself in your project's dev-dependencies section.

Future work includes being able to isolate installing bearboto3 runtime type definitions per service, like you are able to specify with moto and boto3-stubs.

Versioning

For the most part this project will try to adhere to semantic versioning. The first 1.0.0 release will come when type checking for all of the AWS services have been finished. 0.x.0 releases will contain type checking for new services, and 0.x.x releases will contain any fixes on the existing implemented services.

If the community disagrees with this approach and would like to propose an alternative, please feel free to start a discussion or open an issue.

Contributing

See contributing

Acknowledgements

  • @leycec For being an avid supporter and welcoming me to the beartype family

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bearboto3-0.1.3.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

bearboto3-0.1.3-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file bearboto3-0.1.3.tar.gz.

File metadata

  • Download URL: bearboto3-0.1.3.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.2 Linux/5.13.0-1023-azure

File hashes

Hashes for bearboto3-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c2c970f455151baf99732b4722e7dc9f046249db670126e60f0c63283b6781a4
MD5 7581004d3e381a79f0439c736a7c4e5c
BLAKE2b-256 99270bb2c659221b50ac5ce7a53093dd1cf38bab802ef9682e7b05dd489da114

See more details on using hashes here.

File details

Details for the file bearboto3-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: bearboto3-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.2 Linux/5.13.0-1023-azure

File hashes

Hashes for bearboto3-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d7bc218e6d59bc8d5496dba8d0655c407e873ba68e05d025d6039464fedb8ac6
MD5 eccb19920f6fbaf29659c26a57e998cb
BLAKE2b-256 c1699885b854bed1464a01646ba9fb2c723a4d795806849899ca71cfd7e1d7f6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page