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

LastEvaluatedKey in QueryOutputTableTypeDef not treated as Optional contrary to boto3 documentation #324

Closed
Ricool06 opened this issue Oct 31, 2024 · 5 comments
Labels
🐞 bug Something isn't working 🎉 released Changes were included to the latest release 👋 response needed Awaiting response from a reporter

Comments

@Ricool06
Copy link

Describe the bug
LastEvaluatedKey in QueryOutputTableTypeDef is not treated as Optional by boto3-stubs despite it only being present if a DynamoDB query requires pagination. The documentation for boto3 implies that it is optional here.

Happy to submit a PR, but not 100% sure how the type builder works yet.

To Reproduce
Steps to reproduce the behavior:

  1. Install boto3-stubs[...]
  2. Run mypy on the following code sample
import boto3
from mypy_boto3_dynamodb.type_defs import QueryOutputTableTypeDef

response: QueryOutputTableTypeDef = {
        "Items": [],
        "ConsumedCapacity": {},
        "ResponseMetadata": {
            "RequestId": "",
            "HTTPStatusCode": 200,
            "HTTPHeaders": {},
            "RetryAttempts": 0,
        },
        "Count": 0,
        "ScannedCount": 0,
        # "LastEvaluatedKey": {},
    }

Actual output

 error: Missing key "LastEvaluatedKey" for TypedDict "QueryOutputTableTypeDef"  [typeddict-item]

Expected output

Success: no issues found in 1 source file

Additional context
Ubuntu 20.04, installed with poetry add boto3-stubs, boto3 version 1.34.146.

@Ricool06 Ricool06 added the 🐞 bug Something isn't working label Oct 31, 2024
@vemel
Copy link
Collaborator

vemel commented Oct 31, 2024

Hello. Thank you for the report.

Unfortunately, there is no way to tell which keys in output shapes are required or optional, because required array is not present in botocore shapes in 99% of cases. So, builder considers all output keys as required by default.

However, there is a way to manually mark any key as optional here: https://github.com/youtype/mypy_boto3_builder/blob/main/mypy_boto3_builder/type_maps/required_attribute_map.py

So, I am going to add ServiceNameCatalog.dynamodb -> ALL -> LastEvaluatedKey = False in the next release. Let me know if you want to submit a PR.

@vemel vemel added the 👋 response needed Awaiting response from a reporter label Oct 31, 2024
@vemel
Copy link
Collaborator

vemel commented Nov 2, 2024

Fixed in the latest release: https://github.com/youtype/mypy_boto3_builder/releases/tag/8.2.0

Please update mypy-boto3-dynamodb and let me know if it works as expected.

@vemel vemel added the 🎉 released Changes were included to the latest release label Nov 2, 2024
@Ricool06
Copy link
Author

Ricool06 commented Nov 3, 2024

Fixed in the latest release: https://github.com/youtype/mypy_boto3_builder/releases/tag/8.2.0

Please update mypy-boto3-dynamodb and let me know if it works as expected.

Thanks, I wanted to submit a PR but this week has been busy.

@vemel
Copy link
Collaborator

vemel commented Nov 3, 2024

Fixed in the latest release: https://github.com/youtype/mypy_boto3_builder/releases/tag/8.2.0
Please update mypy-boto3-dynamodb and let me know if it works as expected.

Thanks, I wanted to submit a PR but this week has been busy.

Well, if you find any other keys that should be marked as NotRequired in output shapes - you can submit a PR.

@Ricool06
Copy link
Author

Ricool06 commented Nov 4, 2024

Will do, thanks for the hard work. 🙏

@vemel vemel closed this as completed Nov 7, 2024
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