|
1 | | -from __future__ import annotations # backward compatibility |
| 1 | +from typing import Any |
2 | 2 |
|
3 | 3 | import logging |
4 | 4 | from datetime import datetime, timezone |
5 | 5 | from decimal import Decimal |
6 | 6 | import json |
7 | 7 | from types import ModuleType |
8 | | -from typing import Any, Optional, Dict |
9 | 8 |
|
10 | 9 |
|
11 | 10 | BUILTIN_ATTRS: set[str] = { |
@@ -68,7 +67,7 @@ def format(self, record: logging.LogRecord) -> Any | str: |
68 | 67 | message: str = record.getMessage() |
69 | 68 | extra: dict[str, Any] = self.extra_from_record(record) |
70 | 69 | json_record: dict[str, Any] = self.json_record(message, extra, record) |
71 | | - mutated_record: Optional[dict[str, Any]] = self.mutate_json_record(json_record) |
| 70 | + mutated_record: dict[str, Any] = self.mutate_json_record(json_record) |
72 | 71 | # Backwards compatibility: Functions that overwrite this but don't |
73 | 72 | # return a new value will return None because they modified the |
74 | 73 | # argument passed in. |
@@ -135,9 +134,7 @@ def json_record( |
135 | 134 |
|
136 | 135 | return extra |
137 | 136 |
|
138 | | - def mutate_json_record( |
139 | | - self, json_record: dict[str, Any] |
140 | | - ) -> Optional[Dict[str, Any]]: |
| 137 | + def mutate_json_record(self, json_record: dict[str, Any]) -> dict[str, Any]: |
141 | 138 | """Override it to convert fields of `json_record` to needed types. |
142 | 139 |
|
143 | 140 | Default implementation converts `datetime` to string in ISO8601 format. |
|
0 commit comments