Change error message for unbound callbacks in ContextMenu

This commit is contained in:
Rapptz 2022-09-03 22:02:02 -04:00
parent e04af033c0
commit 27b19ed582

View File

@ -433,6 +433,9 @@ def _extract_parameters_from_callback(func: Callable[..., Any], globalns: Dict[s
def _get_context_menu_parameter(func: ContextMenuCallback) -> Tuple[str, Any, AppCommandType]:
params = inspect.signature(func).parameters
if is_inside_class(func) and not hasattr(func, '__self__'):
raise TypeError('context menus cannot be defined inside a class')
if len(params) != 2:
msg = (
f'context menu callback {func.__qualname__!r} requires 2 parameters, '