MousaZeidBaker / aws-lambda-typing

Python type hints for AWS Lambda
MIT License
106 stars 19 forks source link

DynamodbRecord.OldImage shouldn't be optional according to the AWS doc #60

Closed YonatanGreenfeld closed 2 years ago

YonatanGreenfeld commented 2 years ago

Ref: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_StreamRecord.html#:~:text=before%20it%20was%20modified.-,Type%3A%20String%20to%20AttributeValue%20object%20map,-Key%20Length%20Constraints%3A%20Maximum as well as https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodbstreams.html#:~:text=%22BOOL%22%3A%20true-,OldImage,-(dict)%20%2D%2D

Looks like OldImage isn't optional, just like NewImage isn't.

Also, it looks like many fields are annotated as Optional but the docs don't state they are (say userIdentity and ApproximateCreationDateTime in the same file). Is this the desired behaviour?

MousaZeidBaker commented 2 years ago

The aws ref you are linking to states OldImage, userIdentity & ApproximateCreationDateTime as non required, see following screenshots

image image image

In fact even NewImage is non required image

YonatanGreenfeld commented 2 years ago

That's correct. However, in TypedDict terms, Optional is not the same as not required (as you probably know). The class is already not total so I think we just need to remove the Optionals PEP-655

MousaZeidBaker commented 2 years ago

You are correct, its enough with setting total to false