Return type incorrect for DynamoDb Client methods
BrentSouza opened this issue · 2 comments
BrentSouza commented
Describe the bug
For example, Dynamodb.Client.execute_statement()
has a return type ExecuteStatementOutputTypeDef
that is defined as:
ExecuteStatementOutputTypeDef = TypedDict(
"ExecuteStatementOutputTypeDef",
{
"Items": List[Dict[str, TableAttributeValueTypeDef]],
"NextToken": str,
"ConsumedCapacity": ConsumedCapacityTypeDef,
"LastEvaluatedKey": Dict[str, TableAttributeValueTypeDef],
"ResponseMetadata": ResponseMetadataTypeDef,
},
)
However, execute_statement
as returned from the DynamoDB api has a structure like:
{
"Items": [
{ "string0": { "S": "string" } },
{ "string1": { "SS": ["string0", "string1"] } }
],
"LastEvaluatedKey": {
"string": { "S": "string" }
}
}
I believe this is more inline with a type def like:
ExecuteStatementOutputTypeDef = TypedDict(
"ExecuteStatementOutputTypeDef",
{
"Items": List[Dict[str, AttributeValueTypeDef]],
"NextToken": str,
"ConsumedCapacity": ConsumedCapacityTypeDef,
"LastEvaluatedKey": Dict[str, AttributeValueTypeDef],
"ResponseMetadata": ResponseMetadataTypeDef,
},
)
This is also present with DynamoDB.Client.get_item()
.
Compare the response in the docs for Client.get_item() vs Table.get_item()
vemel commented
Thank you for the report. I will try to fix it today. This return type should be only used for Table
resource.
vemel commented
Fixed in mypy-boto3-dynamodb 1.28.19
. Please update and let me know if it works as it should.