make more pythonic

This commit is contained in:
brmnjsh 2023-09-11 13:23:04 +00:00
parent 2ae15f9237
commit 4788012ce6

View File

@ -31,13 +31,7 @@ def get_object(key: str, bucket: str) -> bytes:
def get_object_tag(key: str, bucket: str, tag_key: str) -> Union[str, None]:
tags = get_object_tags(key, bucket)
for i, tag in enumerate(tags):
tag = tags[i]
if tag['Key'] == tag_key:
return tag
else:
return None
return next((tag for tag in tags if tag['Key'] == tag_key), None)
def get_object_tags(key: str, bucket: str) -> list:
tags = s3.get_object_tagging(Bucket=bucket, Key=key)['TagSet']