Skip to content

Commit 1ec9054

Browse files
committed
Factor None out of InstrumentType_co
1 parent 12463a1 commit 1ec9054

File tree

5 files changed

+9
-15
lines changed

5 files changed

+9
-15
lines changed

src/qcodes/parameters/array_parameter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ def __init__(
133133
self,
134134
name: str,
135135
shape: Sequence[int],
136-
# mypy seems to be confused here. The bound and default for InstrumentType_co
137-
# contains None but mypy will now allow it as a default as of v 1.19.0
138-
instrument: InstrumentType_co = None, # type: ignore[assignment]
136+
instrument: InstrumentType_co | None = None,
139137
label: str | None = None,
140138
unit: str | None = None,
141139
setpoints: Sequence[Any] | None = None,

src/qcodes/parameters/delegate_parameter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
_local_ParameterDataTypeVar = TypeVar("_local_ParameterDataTypeVar", default=Any)
2525
_local_InstrumentType_co = TypeVar(
2626
"_local_InstrumentType_co",
27-
bound="InstrumentBase | None",
28-
default="InstrumentBase | None",
27+
bound="InstrumentBase",
28+
default="InstrumentBase",
2929
covariant=True,
3030
)
3131

src/qcodes/parameters/multi_parameter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ def __init__(
141141
name: str,
142142
names: Sequence[str],
143143
shapes: Sequence[Sequence[int]],
144-
# mypy seems to be confused here. The bound and default for InstrumentType_co
145-
# contains None but mypy will now allow it as a default as of v 1.19.0
146-
instrument: InstrumentType_co = None, # type: ignore[assignment]
144+
instrument: InstrumentType_co | None = None,
147145
labels: Sequence[str] | None = None,
148146
units: Sequence[str] | None = None,
149147
setpoints: Sequence[Sequence[Any]] | None = None,

src/qcodes/parameters/parameter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ class Parameter(
180180
def __init__(
181181
self,
182182
name: str,
183-
# mypy seems to be confused here. The bound and default for InstrumentType_co
184-
# contains None but mypy will now allow it as a default as of v 1.19.0
185-
instrument: InstrumentType_co = None, # type: ignore[assignment]
183+
instrument: InstrumentType_co | None = None,
186184
label: str | None = None,
187185
unit: str | None = None,
188186
get_cmd: str | Callable[..., Any] | Literal[False] | None = None,

src/qcodes/parameters/parameter_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
# Type parameter "InstrumentType@ParameterBase" is invariant, but "None" is not the same as "InstrumentBase | None"
5353
InstrumentType_co = TypeVar(
5454
"InstrumentType_co",
55-
bound="InstrumentBase | None",
56-
default="InstrumentBase | None",
55+
bound="InstrumentBase",
56+
default="InstrumentBase",
5757
covariant=True,
5858
)
5959

@@ -229,7 +229,7 @@ class ParameterBase(
229229
def __init__(
230230
self,
231231
name: str,
232-
instrument: InstrumentType_co = None, # type: ignore[assignment]
232+
instrument: InstrumentType_co | None = None,
233233
snapshot_get: bool = True,
234234
metadata: Mapping[Any, Any] | None = None,
235235
step: float | None = None,
@@ -1063,7 +1063,7 @@ def register_name(self) -> str:
10631063
return self._register_name or self.full_name
10641064

10651065
@property
1066-
def instrument(self) -> InstrumentType_co:
1066+
def instrument(self) -> InstrumentType_co | None:
10671067
"""
10681068
Return the first instrument that this parameter is bound to.
10691069
E.g if this is bound to a channel it will return the channel

0 commit comments

Comments
 (0)