Skip to content

Commit 5d0e465

Browse files
committed
remove backward compatibility
1 parent 661269e commit 5d0e465

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

json_log_formatter/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from __future__ import annotations # backward compatibility
1+
from typing import Any
22

33
import logging
44
from datetime import datetime, timezone
55
from decimal import Decimal
66
import json
77
from types import ModuleType
8-
from typing import Any, Optional, Dict
98

109

1110
BUILTIN_ATTRS: set[str] = {
@@ -68,7 +67,7 @@ def format(self, record: logging.LogRecord) -> Any | str:
6867
message: str = record.getMessage()
6968
extra: dict[str, Any] = self.extra_from_record(record)
7069
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)
7271
# Backwards compatibility: Functions that overwrite this but don't
7372
# return a new value will return None because they modified the
7473
# argument passed in.
@@ -135,9 +134,7 @@ def json_record(
135134

136135
return extra
137136

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]:
141138
"""Override it to convert fields of `json_record` to needed types.
142139
143140
Default implementation converts `datetime` to string in ISO8601 format.

tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
from django.core.handlers.wsgi import WSGIRequest
1212
from django.conf import settings
13-
import ujson
14-
import simplejson
13+
import ujson # type: ignore
14+
import simplejson # type: ignore
1515

1616
try:
1717
from cStringIO import StringIO # type: ignore

0 commit comments

Comments
 (0)