Skip to content

Commit c61d0ef

Browse files
committed
Update mypy-boto3 readme
1 parent 7494a0b commit c61d0ef

File tree

1 file changed

+59
-2
lines changed

1 file changed

+59
-2
lines changed

mypy_boto3_builder/templates/master/README.md.jinja2

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ See how it helps to find and fix potential bugs:
2121
## How to install
2222

2323
```bash
24+
# Install this package
25+
python -m pip install mypy-boto3
26+
2427
# Install type annotations for boto3 services you use
2528
python -m pip install 'boto3-stubs[s3,ec2]'
2629

@@ -31,5 +34,59 @@ python -m pip install 'boto3-stubs-lite[s3,ec2]'
3134

3235
## Usage
3336

34-
This tool is not longer required for annotations to work. Do not use it,
35-
install [boto3-stubs](https://pypi.org/project/boto3-stubs/) instead.
37+
Provides `ServiceName` and `ResourceServiceName` literals:
38+
39+
```python
40+
from typing import overload
41+
42+
import boto3
43+
from botocore.client import BaseClient
44+
from mypy_boto3.literals import ServiceName
45+
from mypy_boto3_ec2.client import EC2Client
46+
from mypy_boto3_ec2.literals import EC2ServiceName
47+
from mypy_boto3_s3.client import S3Client
48+
from mypy_boto3_s3.literals import S3ServiceName
49+
50+
51+
@overload
52+
def get_client(service_name: EC2ServiceName) -> EC2Client: ...
53+
54+
55+
@overload
56+
def get_client(service_name: S3ServiceName) -> S3Client: ...
57+
58+
59+
@overload
60+
def get_client(service_name: ServiceName) -> BaseClient: ...
61+
62+
63+
def get_client(service_name: ServiceName) -> BaseClient:
64+
return boto3.client(service_name)
65+
66+
67+
# type: S3Client, fully type annotated
68+
# All methods and attributes are auto-completed and type checked
69+
s3_client = get_client("s3")
70+
71+
# type: EC2Client, fully type annotated
72+
# All methods and attributes are auto-completed and type checked
73+
ec2_client = get_client("ec2")
74+
75+
# type: BaseClient, only basic type annotations
76+
# Dynamodb-specific methods and attributes are not auto-completed and not type checked
77+
dynamodb_client = get_client("dynamodb")
78+
```
79+
80+
### Latest changes
81+
82+
Full changelog can be found in [Releases](https://github.com/youtype/mypy_boto3_builder/releases).
83+
84+
## Versioning
85+
86+
`{{ package.pypi_name }}` version is the same as related `boto3` version and follows
87+
[PEP 440](https://www.python.org/dev/peps/pep-0440/) format.
88+
89+
## Support and contributing
90+
91+
Please reports any bugs or request new features in
92+
[mypy_boto3_builder](https://github.com/youtype/mypy_boto3_builder/issues/) repository.

0 commit comments

Comments
 (0)