Skip to content

Commit b34a45a

Browse files
committed
WIP
1 parent 42e965e commit b34a45a

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ name = "Martin Gaughran"
6060
version_file = "src/fastcs/_version.py"
6161

6262
[tool.pyright]
63-
typeCheckingMode = "standard"
63+
typeCheckingMode = "strict"
6464
reportMissingImports = false # Ignore missing stubs in imported modules
6565

6666
[tool.pytest.ini_options]

src/fastcs/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class method and a controller instance, so that it can be called from any
4040
for attr_name in dir(self):
4141
attr = getattr(self, attr_name)
4242
if isinstance(attr, Attribute):
43-
setattr(self, attr_name, copy(attr))
43+
setattr(self, attr_name, copy(attr)) # type: ignore
4444
elif isinstance(attr, Put | Scan | Command):
4545
setattr(self, attr_name, attr.bind(self))
4646

src/fastcs/cs_methods.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from collections.abc import Callable, Coroutine
33
from inspect import Signature, getdoc, signature
44
from types import MethodType
5-
from typing import Any, Generic, TypeVar
5+
from typing import Any, Concatenate, Generic, ParamSpec, TypeVar
66

77
from fastcs.controller import BaseController
88

@@ -124,24 +124,21 @@ def __call__(self):
124124
raise method_not_bound_error
125125

126126

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+
130130

131+
class BoundScan(Method[BaseController], Generic[P]):
132+
def __init__(self, fn: Callable[Concatenate[ControllerType, P], R], period: float):
133+
self._fn = fn
131134
self._period = period
132135

133136
@property
134137
def period(self):
135138
return self._period
136139

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)
145142

146143

147144
class BoundPut(Method[BaseController]):

0 commit comments

Comments
 (0)