youtype / mypy_boto3_builder

Type annotations builder for boto3 compatible with VSCode, PyCharm, Emacs, Sublime Text, pyright and mypy.
https://youtype.github.io/mypy_boto3_builder/
MIT License
544 stars 36 forks source link

Return type incorrect for DynamoDb Client methods #216

Closed BrentSouza closed 1 year ago

BrentSouza commented 1 year ago

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 1 year ago

Thank you for the report. I will try to fix it today. This return type should be only used for Table resource.

vemel commented 1 year ago

Fixed in mypy-boto3-dynamodb 1.28.19. Please update and let me know if it works as it should.