Skip to content

Commit 5421541

Browse files
committed
chore: add return-type hints and fix write()
1 parent cf961b6 commit 5421541

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/firebase_functions/logger.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def _safe_exception_string(exception: BaseException) -> str:
145145
return exception.__class__.__name__
146146

147147

148-
def _coerce_json_safe(obj: _typing.Any):
148+
def _coerce_json_safe(obj: _typing.Any) -> _typing.Any:
149149
"""
150150
Converts values that survive circular-reference removal into JSON-safe values.
151151
"""
@@ -163,7 +163,7 @@ def _coerce_json_safe(obj: _typing.Any):
163163
return _safe_repr(obj)
164164

165165

166-
def _coerce_json_safe_dict_key(obj: _typing.Any):
166+
def _coerce_json_safe_dict_key(obj: _typing.Any) -> _typing.Any:
167167
"""
168168
Converts dictionary keys into values accepted by JSON object encoding.
169169
"""
@@ -229,7 +229,7 @@ def _get_write_file(severity: LogSeverity) -> _typing.TextIO:
229229

230230
def write(entry: LogEntry) -> None:
231231
write_file = _get_write_file(entry["severity"])
232-
print(_json.dumps(_remove_circular(entry), ensure_ascii=False), file=write_file)
232+
print(_json.dumps(_coerce_json_safe(_remove_circular(entry)), ensure_ascii=False), file=write_file)
233233

234234

235235
def debug(*args, **kwargs) -> None:

0 commit comments

Comments
 (0)