From b8a333004a9d7591ecf2c477c50e06f122f40565 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 5 Feb 2025 13:07:49 +0100 Subject: Fix legacy modules `check_username_for_spam` (#18135) Broke in #17916, as the signature inspection incorrectly looks at the wrapper function. We fix this by setting the signature on the wrapper function to that of the wrapped function via `@functools.wraps`. --- synapse/module_api/callbacks/spamchecker_callbacks.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'synapse/module_api/callbacks/spamchecker_callbacks.py') diff --git a/synapse/module_api/callbacks/spamchecker_callbacks.py b/synapse/module_api/callbacks/spamchecker_callbacks.py index a2f328cafe..9bc572422b 100644 --- a/synapse/module_api/callbacks/spamchecker_callbacks.py +++ b/synapse/module_api/callbacks/spamchecker_callbacks.py @@ -19,6 +19,7 @@ # # +import functools import inspect import logging from typing import ( @@ -297,6 +298,7 @@ def load_legacy_spam_checkers(hs: "synapse.server.HomeServer") -> None: "Bad signature for callback check_registration_for_spam", ) + @functools.wraps(wrapped_func) def run(*args: Any, **kwargs: Any) -> Awaitable: # Assertion required because mypy can't prove we won't change `f` # back to `None`. See -- cgit 1.5.1