Skip to content

Commit 642734f

Browse files
ryandeivertrubenfonseca
authored andcommitted
fixup mypy
1 parent c9b93fc commit 642734f

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

Diff for: aws_lambda_powertools/utilities/data_classes/kinesis_firehose_event.py

+18-13
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,46 @@
66

77

88
class KinesisFirehoseRecordMetadata(DictWrapper):
9+
@property
10+
def _metadata(self) -> dict:
11+
"""Optional: metadata associated with this record; present only when Kinesis Stream is source"""
12+
return self["kinesisRecordMetadata"] # could raise KeyError
13+
914
@property
1015
def shard_id(self) -> Optional[str]:
1116
"""Kinesis stream shard ID; present only when Kinesis Stream is source"""
12-
return self.get("shardId")
17+
return self._metadata.get("shardId")
1318

1419
@property
15-
def partition_key(self) -> Optional[str]
20+
def partition_key(self) -> Optional[str]:
1621
"""Kinesis stream partition key; present only when Kinesis Stream is source"""
17-
return self.get("partitionKey")
22+
return self._metadata.get("partitionKey")
1823

1924
@property
20-
def approximate_arrival_timestamp(self) -> Optional[str]
25+
def approximate_arrival_timestamp(self) -> Optional[str]:
2126
"""Kinesis stream approximate arrival ISO timestamp; present only when Kinesis Stream is source"""
22-
return self.get("approximateArrivalTimestamp")
27+
return self._metadata.get("approximateArrivalTimestamp")
2328

2429
@property
25-
def sequence_number(self) -> Optional[str]
30+
def sequence_number(self) -> Optional[str]:
2631
"""Kinesis stream sequence number; present only when Kinesis Stream is source"""
27-
return self.get("sequenceNumber")
32+
return self._metadata.get("sequenceNumber")
2833

2934
@property
30-
def subsequence_number(self) -> Optional[str]
35+
def subsequence_number(self) -> Optional[str]:
3136
"""Kinesis stream sub-sequence number; present only when Kinesis Stream is source
32-
37+
3338
Note: this will only be present for Kinesis streams using record aggregation
3439
"""
35-
return self.get("subsequenceNumber")
40+
return self._metadata.get("subsequenceNumber")
3641

3742

3843
class KinesisFirehoseRecord(DictWrapper):
3944
@property
4045
def approximate_arrival_timestamp(self) -> float:
4146
"""The approximate time that the record was inserted into the delivery stream"""
4247
return float(self["approximateArrivalTimestamp"])
43-
48+
4449
@property
4550
def record_id(self) -> str:
4651
"""Record ID; uniquely identifies this record within the current batch"""
@@ -52,9 +57,9 @@ def data(self) -> str:
5257
return self["data"]
5358

5459
@property
55-
def metadata(self) -> Optional[KinesisFirehoseRecordMetadata]:
60+
def metadata(self) -> KinesisFirehoseRecordMetadata:
5661
"""Optional: metadata associated with this record; present only when Kinesis Stream is source"""
57-
return KinesisFirehoseRecordMetadata(self.get('kinesisRecordMetadata', {}))
62+
return KinesisFirehoseRecordMetadata(self._data)
5863

5964
@property
6065
def data_as_bytes(self) -> bytes:

0 commit comments

Comments
 (0)