diff --git a/mypy/checker.py b/mypy/checker.py index 33ed5387554d..d9a1f3729c2f 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -5864,6 +5864,10 @@ def visit_decorator_inner( object_type = self.lookup_type(d.expr) fullname = self.expr_checker.method_fullname(object_type, d.name) self.check_for_untyped_decorator(e.func, dec, d) + if fullname: + dec = self.expr_checker.transform_callee_type( + fullname, dec, [temp], [nodes.ARG_POS], e, object_type=object_type + ) sig, t2 = self.expr_checker.check_call( dec, [temp], [nodes.ARG_POS], e, callable_name=fullname, object_type=object_type ) diff --git a/test-data/unit/check-custom-plugin.test b/test-data/unit/check-custom-plugin.test index dd1de1265b59..b79e752ed5ae 100644 --- a/test-data/unit/check-custom-plugin.test +++ b/test-data/unit/check-custom-plugin.test @@ -908,6 +908,19 @@ reveal_type(dynamic_signature(b)) # N: Revealed type is "builtins.bytes" \[mypy] plugins=/test-data/unit/plugins/function_sig_hook.py +[case testFunctionSigHookCalledOnDecorator] +# flags: --config-file tmp/mypy.ini + +def dynamic_signature(arg1: str) -> str: ... + +@dynamic_signature +def f() -> None: ... + +reveal_type(f) # N: Revealed type is "def ()" +[file mypy.ini] +\[mypy] +plugins=/test-data/unit/plugins/function_sig_hook.py + [case testPluginCalledCorrectlyWhenMethodInDecorator] # flags: --config-file tmp/mypy.ini from typing import TypeVar, Callable