From 4aec990c690417d34413e1ff95f36fd1fb8e5f00 Mon Sep 17 00:00:00 2001 From: chillymosh <86857777+chillymosh@users.noreply.github.com> Date: Mon, 7 Oct 2024 20:53:12 +0100 Subject: [PATCH] Fix decorator for typing of existing methods --- twitchio/utils.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/twitchio/utils.py b/twitchio/utils.py index 3d9b1a1f..f44533ff 100644 --- a/twitchio/utils.py +++ b/twitchio/utils.py @@ -740,10 +740,17 @@ def decorator(func: F) -> F: def wrapper(*args: Any, **kwargs: Any) -> Any: from .user import PartialUser - new_args = [(arg.id if isinstance(arg, PartialUser) else arg) for arg in (args[1:] if is_self else args)] - if is_self: - new_args = [args[0], *new_args] - new_kwargs = {k: (v.id if isinstance(v, PartialUser) else v) for k, v in kwargs.items()} + new_args = [ + (str(arg.id) if isinstance(arg, PartialUser) else arg) + for i, arg in enumerate(args) + if not (is_self and i == 0) + ] + + if is_self and args: + new_args.insert(0, args[0]) + + new_kwargs = {k: (str(v.id) if isinstance(v, PartialUser) else v) for k, v in kwargs.items()} + return func(*new_args, **new_kwargs) return cast(F, wrapper)