-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
ListObjectVersionsOutputTypeDef CommonPrefixes key can be missing #248
Comments
Unfortunately, right now there is no way to tell if the key in output shape is optional or not. I am still investigating it. By the way, you are getting key error because method name is incorrect: |
corrected, but this doesn't change my issue: the key is optional from the S3 response but the type checker misses that. |
I will try to fix it. If you have time you can also take a look at One solution would be to use the same key totality as for input shapes. But it is also not an ideal solution, because almost all keys are optional in input shapes. Another solution would be to somehow figure out which keys are required in output shapes, but I still have no idea how to do it. |
If I use the same rules as for input shapes, this is what I get : ListObjectVersionsOutputTypeDef = TypedDict(
"ListObjectVersionsOutputTypeDef",
{
"ResponseMetadata": ResponseMetadataTypeDef,
"IsTruncated": NotRequired[bool],
"KeyMarker": NotRequired[str],
"VersionIdMarker": NotRequired[str],
"NextKeyMarker": NotRequired[str],
"NextVersionIdMarker": NotRequired[str],
"Versions": NotRequired[List[ObjectVersionTypeDef]],
"DeleteMarkers": NotRequired[List[DeleteMarkerEntryTypeDef]],
"Name": NotRequired[str],
"Prefix": NotRequired[str],
"Delimiter": NotRequired[str],
"MaxKeys": NotRequired[int],
"CommonPrefixes": NotRequired[List[CommonPrefixTypeDef]],
"EncodingType": NotRequired[Literal["url"]],
"RequestCharged": NotRequired[Literal["requester"]],
},
) As you see, all keys are marked as not required. I do not think that this is a proper solution. |
The issue has finally been fixed in |
Describe the bug
ListObjectVersionsOutputTypeDef
has the keyCommonPrefixes
typed as aList[CommonPrefixTypeDef]
, but the key can be missing in the response tolist_object_versions
.To Reproduce
Steps to reproduce the behavior:
boto3-stubs[s3]
mypy
/pyright
on the following code sampleActual output
The
CommonPrefixes
is missing from the response and the snippet fails when running on a real-life example.Expected output
There is no expected output, I would have liked my type checker to warn me about a potentially missing key.
Additional context
I'm using macOS 14.2, python 3.9.5, poetry 1.8.1 to manage dependencies, boto3 & boto3-stubs 1.34.31
An example of a response I got from AWS where the key
CommonPrefixes
is missing.The text was updated successfully, but these errors were encountered: