https://github.com/j4c0bs/boto3-type
Pseudo type check for boto3 service resource instances
https://github.com/j4c0bs/boto3-type
aws boto3 botocore
Last synced: 27 days ago
JSON representation
Pseudo type check for boto3 service resource instances
- Host: GitHub
- URL: https://github.com/j4c0bs/boto3-type
- Owner: j4c0bs
- License: bsd-2-clause
- Created: 2020-02-24T01:14:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-18T02:18:35.000Z (almost 6 years ago)
- Last Synced: 2025-11-10T04:38:00.386Z (7 months ago)
- Topics: aws, boto3, botocore
- Language: Python
- Size: 55.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# boto3-type
Lightweight type check for boto3 service, resource instances.
## Install:
```bash
pip install boto3_type
```
## Problem:
```Python
In [1]: import boto3
In [2]: import botocore
In [3]: s3 = boto3.client("s3")
In [4]: type(s3)
Out[4]: botocore.client.S3
In [5]: isinstance(s3, botocore.client.S3)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
----> 1 isinstance(s3, botocore.client.S3)
AttributeError: module 'botocore.client' has no attribute 'S3'
```
## Usage:
```Python
In [1]: import boto3
In [2]: import boto3_type as bt
In [3]: client = boto3.client("ecs")
In [4]: resource = boto3.resource("s3")
In [5]: bucket = resource.Bucket("test-bucket")
In [6]: bt.is_client(client)
Out[6]: True
In [7]: bt.client.istype(client, "ecs")
Out[7]: True
In [8]: bt.is_resource(resource)
Out[8]: True
In [9]: bt.resource.istype(resource, "s3")
Out[9]: True
In [10]: bt.s3.istype(bucket, "bucket")
Out[10]: True
In [11]: bt.is_resource(client)
Out[11]: False
In [12]: bt.is_client(resource)
Out[12]: False
```