Skip to content

Commit 4832d37

Browse files
committed
Fix nits in code review
1 parent 1226b51 commit 4832d37

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

providers/amazon/src/airflow/providers/amazon/aws/log/cloudwatch_task_handler.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def json_serialize(value: Any) -> str | None:
8181
class DateTimeEncoder(json.JSONEncoder):
8282
"""Custom JSON encoder to handle datetime serialization."""
8383

84-
def default(self, obj):
84+
def default(self, obj: object) -> str:
8585
if isinstance(obj, datetime):
8686
return obj.isoformat()
8787
return super().default(obj)
@@ -180,17 +180,15 @@ def upload(self, path: os.PathLike | str, ti: RuntimeTI):
180180

181181
def read(self, relative_path, ti: RuntimeTI) -> LegacyLogResponse:
182182
messages, logs = self.stream(relative_path, ti)
183+
str_logs: list[str] = []
183184

184-
return messages, [
185-
json.dumps(
186-
msg,
187-
cls=DateTimeEncoder,
188-
)
189-
if isinstance(msg, dict)
190-
else msg
191-
for group in logs
192-
for msg in group
193-
]
185+
for group in logs:
186+
for msg in group:
187+
if isinstance(msg, dict):
188+
msg = json.dumps(msg, cls=DateTimeEncoder)
189+
str_logs.append(msg)
190+
191+
return messages, str_logs
194192

195193
def stream(self, relative_path, ti: RuntimeTI) -> LogResponse:
196194
logs: list[RawLogStream] = []

0 commit comments

Comments
 (0)