summary refs log tree commit diff
path: root/synapse/logging/utils.py
diff options
context:
space:
mode:
authorDan Callahan <danc@element.io>2021-10-27 20:04:00 +0100
committerDan Callahan <danc@element.io>2021-10-27 20:04:00 +0100
commit0dffa9d0e096e5ff04768b2e06ce4acf92120486 (patch)
treeaa501e65702a3e3fb179c3a0c37dc15543637f72 /synapse/logging/utils.py
parentChangelog (diff)
parentAnnotate `log_function` decorator (#10943) (diff)
downloadsynapse-0dffa9d0e096e5ff04768b2e06ce4acf92120486.tar.xz
Merge remote-tracking branch 'origin/develop' into shellcheck
Fixes a merge conflict with debian/changelog

Signed-off-by: Dan Callahan <danc@element.io>
Diffstat (limited to 'synapse/logging/utils.py')
-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)