Notes
As you know, the builder not only generates type annotations, but it also supplies tons of `TypeDef`s that you can use in your code for type checking. Starting from this release `TypeDef`s not only generated for `TypedDict`s to help you with method inputs and outputs, but they also include named `Union`s!
This is especially helpful for `dynamodb` service because it has a complex `TableAttributeTypeDef` `Union`. However, I added support for all `Union`s, even for small ones, even for the ones added in version `7.16.0` to merge input and output shapes! Just import them from `<service_name>.type_defs` and start using them in your projects!
Small usage example just for you:
python
import boto3
from mypy_boto3_s3.type_defs import BlobTypeDef, PutObjectOutputTypeDef
BlobTypeDef is a Union[str, bytes, IO[Any], botocore.response.StreamingBody]
let's use it in our function!
def put_object(body: BlobTypeDef) -> PutObjectOutputTypeDef:
s3_client = boto3.client("s3")
return s3_client.put_object(body=body)
Keep on keeping on!
Added
- `[services]` All `Union`s now have named type annotations in `type_defs.py` (requested by perlow in 196)
- `[builder]` `TypeUnion` type annotation to support named `Union`s
- `[builder]` `TypeDefSortable` protocol to topologically sort both `TypedDict`s and `Union`s
- `[docs]` Added named `Union`s support
Changed
- `[docs]` `TypeDef` usage examples were removed to make docs lighter
Fixed
- `[builder]` Formatting with `black` and `isort` uses temp path
- `[builder]` Moved reusable templates to `templates/common`
- `[dynamodb]` Replace `AttributeValueTypeDef` with `TableAttributeValueTypeDef` in `Table` methods output (reported by fizyk in 210)
- `[iam]` Fixed `PolicyDocumentTypeDef` with hardcode, bug in `botocore` (reported by skeggsein 212)