Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return type incorrect for DynamoDb Client methods #216

Closed
BrentSouza opened this issue Aug 3, 2023 · 2 comments
Closed

Return type incorrect for DynamoDb Client methods #216

BrentSouza opened this issue Aug 3, 2023 · 2 comments
Labels
🐞 bug Something isn't working 🎉 released Changes were included to the latest release 👋 response needed Awaiting response from a reporter

Comments

@BrentSouza
Copy link

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()

@BrentSouza BrentSouza added the 🐞 bug Something isn't working label Aug 3, 2023
@vemel
Copy link
Collaborator

vemel commented Aug 3, 2023

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

@vemel
Copy link
Collaborator

vemel commented Aug 4, 2023

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

@vemel vemel added 👋 response needed Awaiting response from a reporter 🎉 released Changes were included to the latest release labels Aug 4, 2023
@vemel vemel closed this as completed Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 🎉 released Changes were included to the latest release 👋 response needed Awaiting response from a reporter
Projects
None yet
Development

No branches or pull requests

2 participants