summary refs log tree commit diff
path: root/synapse/logging
diff options
context:
space:
mode:
authorreivilibre <oliverw@matrix.org>2021-10-27 17:27:23 +0100
committerGitHub <noreply@github.com>2021-10-27 17:27:23 +0100
commit75ca0a6168f92dab3255839cf85fb0df3a0076c3 (patch)
treeb4326bf5fae23b6df52d9f43dbc6d1ddce3b68c6 /synapse/logging
parentFixed config parse bug in review_recent_signups (#11191) (diff)
downloadsynapse-75ca0a6168f92dab3255839cf85fb0df3a0076c3.tar.xz
Annotate `log_function` decorator (#10943)
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
Diffstat (limited to 'synapse/logging')
-rw-r--r--synapse/logging/utils.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/synapse/logging/utils.py b/synapse/logging/utils.py
index 08895e72ee..4a01b902c2 100644
--- a/synapse/logging/utils.py
+++ b/synapse/logging/utils.py
@@ -16,6 +16,7 @@
 import logging
 from functools import wraps
 from inspect import getcallargs
+from typing import Callable, TypeVar, cast
 
 _TIME_FUNC_ID = 0
 
@@ -41,7 +42,10 @@ def _log_debug_as_f(f, msg, msg_args):
         logger.handle(record)
 
 
-def log_function(f):
+F = TypeVar("F", bound=Callable)
+
+
+def log_function(f: F) -> F:
     """Function decorator that logs every call to that function."""
     func_name = f.__name__
 
@@ -69,4 +73,4 @@ def log_function(f):
         return f(*args, **kwargs)
 
     wrapped.__name__ = func_name
-    return wrapped
+    return cast(F, wrapped)