Skip to content

Commit cfb660f

Browse files
authored
Merge branch 'awslabs:develop' into feat(event-source)-1656-s3-event-eventbridge-dataclass
2 parents 6d1aa80 + 4b0914b commit cfb660f

File tree

10 files changed

+134
-69
lines changed

10 files changed

+134
-69
lines changed

.github/workflows/publish_v2_layer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
# NOTE: we need QEMU to build Layer against a different architecture (e.g., ARM)
6666
- name: Set up Docker Buildx
6767
id: builder
68-
uses: docker/setup-buildx-action@f03ac48505955848960e80bbb68046aa35c7b9e7 # v2.4.1
68+
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0
6969
with:
7070
install: true
7171
driver: docker

aws_lambda_powertools/logging/formatter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def __init__(
137137
self.use_rfc3339_iso8601 = use_rfc3339
138138

139139
if self.utc:
140-
self.converter = time.gmtime # type: ignore
140+
self.converter = time.gmtime
141141

142142
super(LambdaPowertoolsFormatter, self).__init__(datefmt=self.datefmt)
143143

@@ -176,7 +176,7 @@ def formatTime(self, record: logging.LogRecord, datefmt: Optional[str] = None) -
176176
return ts_as_datetime.isoformat(timespec="milliseconds") # 2022-10-27T17:42:26.841+0200
177177

178178
# converts to local/UTC TZ as struct time
179-
record_ts = self.converter(record.created) # type: ignore
179+
record_ts = self.converter(record.created)
180180

181181
if datefmt is None: # pragma: no cover, it'll always be None in std logging, but mypy
182182
datefmt = self.datefmt

aws_lambda_powertools/tracing/base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numbers
33
import traceback
44
from contextlib import contextmanager
5-
from typing import Any, Generator, List, NoReturn, Optional, Sequence, Union
5+
from typing import Any, Generator, List, Optional, Sequence, Union
66

77

88
class BaseSegment(abc.ABC):
@@ -28,7 +28,7 @@ def remove_subsegment(self, subsegment: Any):
2828
"""Remove input subsegment from child subsegments."""
2929

3030
@abc.abstractmethod
31-
def put_annotation(self, key: str, value: Union[str, numbers.Number, bool]) -> NoReturn:
31+
def put_annotation(self, key: str, value: Union[str, numbers.Number, bool]) -> None:
3232
"""Annotate segment or subsegment with a key-value pair.
3333
3434
Note: Annotations will be indexed for later search query.
@@ -42,7 +42,7 @@ def put_annotation(self, key: str, value: Union[str, numbers.Number, bool]) -> N
4242
"""
4343

4444
@abc.abstractmethod
45-
def put_metadata(self, key: str, value: Any, namespace: str = "default") -> NoReturn:
45+
def put_metadata(self, key: str, value: Any, namespace: str = "default") -> None:
4646
"""Add metadata to segment or subsegment. Metadata is not indexed
4747
but can be later retrieved by BatchGetTraces API.
4848
@@ -101,7 +101,7 @@ def in_subsegment_async(self, name=None, **kwargs) -> Generator[BaseSegment, Non
101101
"""
102102

103103
@abc.abstractmethod
104-
def put_annotation(self, key: str, value: Union[str, numbers.Number, bool]) -> NoReturn:
104+
def put_annotation(self, key: str, value: Union[str, numbers.Number, bool]) -> None:
105105
"""Annotate current active trace entity with a key-value pair.
106106
107107
Note: Annotations will be indexed for later search query.
@@ -115,7 +115,7 @@ def put_annotation(self, key: str, value: Union[str, numbers.Number, bool]) -> N
115115
"""
116116

117117
@abc.abstractmethod
118-
def put_metadata(self, key: str, value: Any, namespace: str = "default") -> NoReturn:
118+
def put_metadata(self, key: str, value: Any, namespace: str = "default") -> None:
119119
"""Add metadata to the current active trace entity.
120120
121121
Note: Metadata is not indexed but can be later retrieved by BatchGetTraces API.
@@ -131,7 +131,7 @@ def put_metadata(self, key: str, value: Any, namespace: str = "default") -> NoRe
131131
"""
132132

133133
@abc.abstractmethod
134-
def patch(self, modules: Sequence[str]) -> NoReturn:
134+
def patch(self, modules: Sequence[str]) -> None:
135135
"""Instrument a set of supported libraries
136136
137137
Parameters
@@ -141,5 +141,5 @@ def patch(self, modules: Sequence[str]) -> NoReturn:
141141
"""
142142

143143
@abc.abstractmethod
144-
def patch_all(self) -> NoReturn:
144+
def patch_all(self) -> None:
145145
"""Instrument all supported libraries"""

aws_lambda_powertools/tracing/tracer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ async def async_tasks():
529529
return self._decorate_generator_function(
530530
method=method, capture_response=capture_response, capture_error=capture_error, method_name=method_name
531531
)
532-
elif hasattr(method, "__wrapped__") and inspect.isgeneratorfunction(method.__wrapped__): # type: ignore
532+
elif hasattr(method, "__wrapped__") and inspect.isgeneratorfunction(method.__wrapped__):
533533
return self._decorate_generator_function_with_context_manager(
534534
method=method, capture_response=capture_response, capture_error=capture_error, method_name=method_name
535535
)

aws_lambda_powertools/utilities/parameters/dynamodb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,4 @@ def _get_multiple(self, path: str, **sdk_options) -> Dict[str, str]:
222222

223223
# maintenance: look for better ways to correctly type DynamoDB multiple return types
224224
# without a breaking change within ABC return type
225-
return {item[self.sort_attr]: item[self.value_attr] for item in items} # type: ignore[misc]
225+
return {item[self.sort_attr]: item[self.value_attr] for item in items}

aws_lambda_powertools/utilities/parser/envelopes/kafka.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ def parse(self, data: Optional[Union[Dict[str, Any], Any]], model: Type[Model])
3333
List of records parsed with model provided
3434
"""
3535
event_source = cast(dict, data).get("eventSource")
36-
model_parse_event = KafkaMskEventModel if event_source == "aws:kafka" else KafkaSelfManagedEventModel
36+
model_parse_event: Union[Type[KafkaMskEventModel], Type[KafkaSelfManagedEventModel]] = (
37+
KafkaMskEventModel if event_source == "aws:kafka" else KafkaSelfManagedEventModel
38+
)
3739

3840
logger.debug(f"Parsing incoming data with Kafka event model {model_parse_event}")
3941
parsed_envelope = model_parse_event.parse_obj(data)

aws_lambda_powertools/utilities/streaming/_s3_seekable_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import io
22
import logging
3-
from typing import IO, TYPE_CHECKING, AnyStr, Iterable, List, Optional
3+
from typing import IO, TYPE_CHECKING, AnyStr, Iterable, List, Optional, cast
44

55
import boto3
66

@@ -85,7 +85,7 @@ def raw_stream(self) -> PowertoolsStreamingBody:
8585
self._raw_stream = self.s3_client.get_object(Range=range_header, **self._sdk_options).get("Body")
8686
self._closed = False
8787

88-
return self._raw_stream
88+
return cast(PowertoolsStreamingBody, self._raw_stream)
8989

9090
def seek(self, offset: int, whence: int = io.SEEK_SET) -> int:
9191
"""

mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ warn_unused_ignores=True
77
show_column_numbers = True
88
show_error_codes = True
99
show_error_context = True
10+
disable_error_code = annotation-unchecked
1011

1112
[mypy-jmespath]
1213
ignore_missing_imports=True

0 commit comments

Comments
 (0)