|
15 | 15 | MultiParameter, |
16 | 16 | Parameter, |
17 | 17 | ) |
18 | | -from qcodes.parameters.multi_channel_instrument_parameter import InstrumentModuleType |
19 | 18 | from qcodes.utils import full_class |
20 | 19 | from qcodes.validators import Validator |
21 | 20 |
|
|
27 | 26 | from .instrument_base import InstrumentBaseKWArgs |
28 | 27 |
|
29 | 28 |
|
| 29 | +# Cannot convert to PEP 695: uses default= and covariant= which require PEP 696 (Python 3.13+). |
30 | 30 | _TIB_co = TypeVar( |
31 | 31 | "_TIB_co", bound="InstrumentBase", default=InstrumentBase, covariant=True |
32 | 32 | ) |
@@ -98,10 +98,7 @@ class InstrumentChannel(InstrumentModule[_TIB_co], Generic[_TIB_co]): |
98 | 98 | pass |
99 | 99 |
|
100 | 100 |
|
101 | | -T = TypeVar("T", bound="ChannelTuple") |
102 | | - |
103 | | - |
104 | | -class ChannelTuple(MetadatableWithName, Sequence[InstrumentModuleType]): |
| 101 | +class ChannelTuple[InstrumentModuleType: "InstrumentModule"](MetadatableWithName, Sequence[InstrumentModuleType]): |
105 | 102 | """ |
106 | 103 | Container for channelized parameters that allows for sweeps over |
107 | 104 | all channels, as well as addressing of individual channels. |
@@ -628,7 +625,7 @@ def invalidate_cache(self) -> None: |
628 | 625 |
|
629 | 626 | # in index method the parameter obj should be called value but that would |
630 | 627 | # be an incompatible change |
631 | | -class ChannelList( # pyright: ignore[reportIncompatibleMethodOverride] |
| 628 | +class ChannelList[InstrumentModuleType: "InstrumentModule"]( # pyright: ignore[reportIncompatibleMethodOverride] |
632 | 629 | ChannelTuple[InstrumentModuleType], MutableSequence[InstrumentModuleType] |
633 | 630 | ): |
634 | 631 | """ |
@@ -1161,10 +1158,8 @@ def exists_on_instrument(self) -> bool: |
1161 | 1158 | return self._exists_on_instrument |
1162 | 1159 |
|
1163 | 1160 |
|
1164 | | -TAUTORELOADCHANNEL = TypeVar("TAUTORELOADCHANNEL", bound=AutoLoadableInstrumentChannel) |
1165 | 1161 |
|
1166 | | - |
1167 | | -class AutoLoadableChannelList(ChannelList[TAUTORELOADCHANNEL]): |
| 1162 | +class AutoLoadableChannelList[TAUTORELOADCHANNEL: AutoLoadableInstrumentChannel](ChannelList[TAUTORELOADCHANNEL]): |
1168 | 1163 | """ |
1169 | 1164 | Extends the QCoDeS :class:`ChannelList` class to add the following features: |
1170 | 1165 | - Automatically create channel objects on initialization |
@@ -1243,3 +1238,16 @@ def add(self, **kwargs: Any) -> TAUTORELOADCHANNEL: |
1243 | 1238 |
|
1244 | 1239 | self.append(new_channel) |
1245 | 1240 | return new_channel |
| 1241 | + |
| 1242 | + |
| 1243 | +if not TYPE_CHECKING: |
| 1244 | + from qcodes.utils.deprecate import _make_deprecated_typevars_getattr |
| 1245 | + |
| 1246 | + _deprecated_typevars: dict[str, TypeVar] = { |
| 1247 | + "T": TypeVar("T", bound="ChannelTuple"), |
| 1248 | + "TAUTORELOADCHANNEL": TypeVar( |
| 1249 | + "TAUTORELOADCHANNEL", bound=AutoLoadableInstrumentChannel |
| 1250 | + ), |
| 1251 | + } |
| 1252 | + |
| 1253 | + __getattr__ = _make_deprecated_typevars_getattr(__name__, _deprecated_typevars) |
0 commit comments