diff --git a/mypy.ini b/mypy.ini
index 568166db33..7760ea3d42 100644
--- a/mypy.ini
+++ b/mypy.ini
@@ -96,6 +96,9 @@ files =
[mypy-synapse.handlers.*]
disallow_untyped_defs = True
+[mypy-synapse.logging.formatter]
+disallow_untyped_defs = True
+
[mypy-synapse.rest.*]
disallow_untyped_defs = True
diff --git a/synapse/logging/formatter.py b/synapse/logging/formatter.py
index c0f12ecd15..bbfd08b9b9 100644
--- a/synapse/logging/formatter.py
+++ b/synapse/logging/formatter.py
@@ -16,6 +16,13 @@
import logging
import traceback
from io import StringIO
+from types import TracebackType
+from typing import Optional, Tuple, Type, Union
+
+ExceptionInfo = Union[
+ Tuple[Type[BaseException], BaseException, Optional[TracebackType]],
+ Tuple[None, None, None],
+]
class LogFormatter(logging.Formatter):
@@ -28,10 +35,7 @@ class LogFormatter(logging.Formatter):
where it was caught are logged).
"""
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
-
- def formatException(self, ei):
+ def formatException(self, ei: ExceptionInfo) -> str:
sio = StringIO()
(typ, val, tb) = ei
|