Bug Report
It seems to me there is no way to intercept and change the signature of a decorator during the invocation.
I see that get_function_hook has been called for foo.deco (eventually allowing me to change the return type of the decorator) but get_function_signature_hook is missing
To Reproduce
very basic example:
foo.py
from collections.abc import Callable
def deco(fun: Callable[..., None]) -> None: ...
@deco
def fun() -> None: ...
plug.py
from mypy.plugin import *
from mypy.types import *
from collections.abc import Callable
class CustomPlugin(Plugin):
def get_function_hook(self, fullname: str) -> Callable[[FunctionContext], Type] | None:
print(f'get_function_hook - {fullname=}')
return None
def get_function_signature_hook(self, fullname: str) -> Callable[[FunctionSigContext], FunctionLike] | None:
print(f'get_function_signature_hook - {fullname=}')
return None
def plugin(_version: str, /) -> type[Plugin]:
return CustomPlugin
If I run mypy with the plugin and capture the stdout I get (avoiding the duplicates):
get_function_hook - fullname='enum.auto'
get_function_hook - fullname='foo.deco'
get_function_hook - fullname='<list>'
get_function_hook - fullname='typing_extensions.disjoint_base'
get_function_hook - fullname='typing_extensions.final'
get_function_hook - fullname='typing.final'
get_function_hook - fullname='typing.runtime_checkable'
get_function_hook - fullname='typing.type_check_only'
get_function_hook - fullname='warnings.deprecated'
get_function_signature_hook - fullname='enum.auto'
get_function_signature_hook - fullname='warnings.deprecate
Expected Behavior
get_function_signature_hook is called also for foo.deco
Actual Behavior
it's missing
Your Environment
mypy 2.3.1 (compiled: yes)
Python 3.14.0
Bug Report
It seems to me there is no way to intercept and change the signature of a decorator during the invocation.
I see that
get_function_hookhas been called forfoo.deco(eventually allowing me to change the return type of the decorator) butget_function_signature_hookis missingTo Reproduce
very basic example:
foo.py
plug.py
If I run
mypywith the plugin and capture the stdout I get (avoiding the duplicates):Expected Behavior
get_function_signature_hookis called also forfoo.decoActual Behavior
it's missing
Your Environment
mypy 2.3.1 (compiled: yes)
Python 3.14.0