|
2 | 2 | from collections.abc import Callable, Coroutine |
3 | 3 | from inspect import Signature, getdoc, signature |
4 | 4 | from types import MethodType |
5 | | -from typing import Any, Generic, TypeVar |
| 5 | +from typing import Any, Concatenate, Generic, ParamSpec, TypeVar |
6 | 6 |
|
7 | 7 | from fastcs.controller import BaseController |
8 | 8 |
|
@@ -124,24 +124,21 @@ def __call__(self): |
124 | 124 | raise method_not_bound_error |
125 | 125 |
|
126 | 126 |
|
127 | | -class BoundScan(Method[BaseController]): |
128 | | - def __init__(self, fn: BoundScanCallback, period: float): |
129 | | - super().__init__(fn) |
| 127 | +P = ParamSpec("P") |
| 128 | +R = TypeVar("R") |
| 129 | + |
130 | 130 |
|
| 131 | +class BoundScan(Method[BaseController], Generic[P]): |
| 132 | + def __init__(self, fn: Callable[Concatenate[ControllerType, P], R], period: float): |
| 133 | + self._fn = fn |
131 | 134 | self._period = period |
132 | 135 |
|
133 | 136 | @property |
134 | 137 | def period(self): |
135 | 138 | return self._period |
136 | 139 |
|
137 | | - def _validate(self, fn: BoundScanCallback) -> None: |
138 | | - super()._validate(fn) |
139 | | - |
140 | | - if not len(self.parameters) == 0: |
141 | | - raise FastCSException("Scan method cannot have arguments") |
142 | | - |
143 | | - def __call__(self): |
144 | | - return self._fn() |
| 140 | + def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R: |
| 141 | + return self._fn(*args, **kwargs) |
145 | 142 |
|
146 | 143 |
|
147 | 144 | class BoundPut(Method[BaseController]): |
|
0 commit comments