From bc77bd7e015fd0cba2844b2f9d3be7f2c3cd9282 Mon Sep 17 00:00:00 2001 From: Matthew Vine <32849887+MattTheCuber@users.noreply.github.com> Date: Thu, 8 Oct 2026 09:36:37 -0400 Subject: [PATCH 1/2] chore: add typing to controller_decorator --- src/trame_common/decorators/klass.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/trame_common/decorators/klass.py b/src/trame_common/decorators/klass.py index 7aba102..e3a5161 100644 --- a/src/trame_common/decorators/klass.py +++ b/src/trame_common/decorators/klass.py @@ -2,9 +2,11 @@ import inspect import logging from collections.abc import Callable -from typing import Any, TypeVar +from typing import Any, ParamSpec, TypeVar F = TypeVar("F", bound=Callable[..., Any]) +P = ParamSpec("P") +R = TypeVar("R") logger = logging.getLogger(__name__) @@ -128,9 +130,9 @@ def decorate(f: F) -> F: return decorate -def controller_decorator(method): - def decorator(*args): - def decorate(f): +def controller_decorator(method: str) -> Callable[..., Callable[[Callable[P, R]], Callable[P, R]]]: + def decorator(*args: str) -> Callable[[Callable[P, R]], Callable[P, R]]: + def decorate(f: Callable[P, R]) -> Callable[P, R]: if not hasattr(f, "_trame_controller"): f._trame_controller = [] for name in args: From f1b644f653aa4cc47ae9a9ecd88d8cd81ac503c6 Mon Sep 17 00:00:00 2001 From: Matthew Vine <32849887+MattTheCuber@users.noreply.github.com> Date: Thu, 8 Oct 2026 09:43:14 -0400 Subject: [PATCH 2/2] chore: format code --- src/trame_common/decorators/klass.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/trame_common/decorators/klass.py b/src/trame_common/decorators/klass.py index e3a5161..10853e6 100644 --- a/src/trame_common/decorators/klass.py +++ b/src/trame_common/decorators/klass.py @@ -130,7 +130,9 @@ def decorate(f: F) -> F: return decorate -def controller_decorator(method: str) -> Callable[..., Callable[[Callable[P, R]], Callable[P, R]]]: +def controller_decorator( + method: str, +) -> Callable[..., Callable[[Callable[P, R]], Callable[P, R]]]: def decorator(*args: str) -> Callable[[Callable[P, R]], Callable[P, R]]: def decorate(f: Callable[P, R]) -> Callable[P, R]: if not hasattr(f, "_trame_controller"):