A. Yes.
from functools import wraps
from typing import Any, Callable, TypeVar, cast
FuncType = TypeVar("FuncType", bound=Callable[..., Any])
def print_funcname(func: FuncType) -> FuncType:
@wraps(func)
def wrapper():
print("Function name:", func.__name__)
func()
return cast(FuncType, wrapper)
@print_funcname
def hello():
print("Hello!")
Recommended Posts