refactor: adding type annotations from mypy stubs#256
Conversation
| **params | ||
| optional_params["ClientToken"] = client_token | ||
|
|
||
| result: CheckpointDurableExecutionResponseTypeDef = ( |
There was a problem hiding this comment.
I'd be very tempted to keep this MutableMapping[str, Any] instead of CheckpointDurableExecutionResponseTypeDef - we're immediately serializing the result into a custom dataclass from a dict, and this way we avoid the extra cast..
What do you think?
There was a problem hiding this comment.
Since cast() has virtually zero runtime cost - it just returns the value unchanged, purely a type checker hint - I'd keep the specific TypeDefs.
I see some trends about Python ecosystem is moving towards more stricter typing, and mypy isn't the only option anymore. We now have ty from Astral (the ruff folks) which is gaining traction. Using precise types now means we're better positioned as the tooling improves.
Personally I'd keep it, but happy to revert.
| CheckpointToken=checkpoint_token, | ||
| Marker=next_marker, | ||
| MaxItems=max_items, | ||
| result: GetDurableExecutionStateResponseTypeDef = ( |
There was a problem hiding this comment.
similar here on MutableMapping
Closes #255
Description of changes:
I added
boto3-stubs[lambda]as a dev dependency for type checking. The boto3 client is now typed asBoto3LambdaClientand API responses use the proper TypeDefs to make it type safe.boto3-stubs[lambda] downloads - https://pypistats.org/packages/mypy-boto3-lambda
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.