From b51aafa77ee08ac6d542fa82b7271ca466759acb Mon Sep 17 00:00:00 2001 From: Devin Burke Date: Wed, 18 Sep 2024 11:09:33 +0200 Subject: [PATCH] Refactored PerSignalConfig to better support type checkers --- src/ophyd_async/core/_readable.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ophyd_async/core/_readable.py b/src/ophyd_async/core/_readable.py index a262a7f0f1..261ce6cc9e 100644 --- a/src/ophyd_async/core/_readable.py +++ b/src/ophyd_async/core/_readable.py @@ -1,7 +1,7 @@ import asyncio import warnings from contextlib import contextmanager -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import ( Any, Callable, @@ -32,12 +32,12 @@ @dataclass -class PerSignalConfig(Dict[SignalW[T], T]): - _signal_configuration: Dict[SignalW[Any], Any] = field(default_factory=dict) +class PerSignalConfig(Dict[SignalW, Any]): + def __setitem__(self, signal: SignalW[T], value: T): + super().__setitem__(signal, value) - @property - def signal_configuration(self) -> Dict[SignalW[Any], Any]: - return self._signal_configuration + def __getitem__(self, signal: SignalW[T]) -> T: + return super().__getitem__[signal] class StandardReadable(