Skip to content

Commit 3bf10d8

Browse files
authored
Merge pull request #7850 from jenshnielsen/ruff_0_15
Upgrade ruff to 0.15.0
2 parents ff4291b + 3f3c76d commit 3bf10d8

15 files changed

Lines changed: 32 additions & 32 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
33
# Ruff version.
4-
rev: v0.14.14
4+
rev: v0.15.0
55
hooks:
66
- id: ruff-check
77
types_or: [python, pyi, jupyter, toml]

docs/examples/DataSet/Measuring X as a function of time.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@
7777
"metadata": {},
7878
"outputs": [],
7979
"source": [
80-
"noise = Parameter(\n",
81-
" \"noise\", label=\"Position\", unit=\"m\", get_cmd=lambda: np.random.randn()\n",
82-
")\n",
80+
"noise = Parameter(\"noise\", label=\"Position\", unit=\"m\", get_cmd=np.random.randn)\n",
8381
"time = ElapsedTimeParameter(\"time\")"
8482
]
8583
},

src/qcodes/dataset/data_set_protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import warnings
66
from collections.abc import Callable, Mapping, Sequence
7-
from enum import Enum
7+
from enum import StrEnum
88
from importlib.metadata import entry_points
99
from pathlib import Path
1010
from typing import (
@@ -555,6 +555,6 @@ def dependent_parameters(self) -> tuple[ParamSpecBase, ...]:
555555
return tuple(self.description.interdeps.dependencies.keys())
556556

557557

558-
class DataSetType(str, Enum):
558+
class DataSetType(StrEnum):
559559
DataSet = "DataSet"
560560
DataSetInMem = "DataSetInMem"

src/qcodes/instrument/delegate/instrument_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(
4444
super().__init__(name=name, **kwargs)
4545

4646
module_name = ".".join(submodules_type.split(".")[:-1])
47-
instr_class_name = submodules_type.split(".")[-1]
47+
instr_class_name = submodules_type.rsplit(".", maxsplit=1)[-1]
4848
module = importlib.import_module(module_name)
4949
instr_class = getattr(module, instr_class_name)
5050

src/qcodes/instrument_drivers/QDev/QDac_channels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def _num_verbose(self, s: str) -> float:
450450
value descriptor.
451451
"""
452452
if self.verbose.get_latest():
453-
s = s.split(": ")[-1]
453+
s = s.rsplit(": ", maxsplit=1)[-1]
454454
return float(s)
455455

456456
def _current_parser(self, s: str) -> float:

src/qcodes/instrument_drivers/american_magnetics/AMI430_visa.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ def __init__(
7272
"enabled",
7373
label="Switch Heater Enabled",
7474
get_cmd=self._check_enabled,
75-
set_cmd=lambda x: (self._enable() if x else self._disable()),
75+
set_cmd=lambda x: self._enable() if x else self._disable(),
7676
vals=Bool(),
7777
)
7878
"""Parameter enabled"""
7979
self.state: Parameter = self.add_parameter(
8080
"state",
8181
label="Switch Heater On",
8282
get_cmd=self._check_state,
83-
set_cmd=lambda x: (self._on() if x else self._off()),
83+
set_cmd=lambda x: self._on() if x else self._off(),
8484
vals=Bool(),
8585
)
8686
"""Parameter state. Always False is the switch heater is not enabled"""
@@ -262,8 +262,8 @@ def __init__(
262262
"""Parameter current_ramp_limit"""
263263
self.field_ramp_limit: Parameter = self.add_parameter(
264264
"field_ramp_limit",
265-
get_cmd=lambda: self.current_ramp_limit(),
266-
set_cmd=lambda x: self.current_ramp_limit(x),
265+
get_cmd=self.current_ramp_limit,
266+
set_cmd=self.current_ramp_limit,
267267
scale=1 / float(self.ask("COIL?")),
268268
unit="T/s",
269269
)

src/qcodes/instrument_drivers/oxford/MercuryiPS_VISA.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def _temp_parser(response: str) -> float:
7373
response: What comes back from instrument.ask
7474
7575
"""
76-
return float(response.split(":")[-1][:-1])
76+
return float(response.rsplit(":", maxsplit=1)[-1][:-1])
7777

7878

7979
class OxfordMercuryWorkerPS(InstrumentChannel):

src/qcodes/instrument_drivers/oxford/triton.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def _get_control_Bcomp_param(self, param: str) -> float | str | list[float] | No
306306
return self._get_response_value(self.ask(cmd[:-2]) + cmd[-2:])
307307

308308
def _get_response(self, msg: str) -> str:
309-
return msg.split(":")[-1]
309+
return msg.rsplit(":", maxsplit=1)[-1]
310310

311311
def _get_response_value(self, msg: str) -> float | str | list[float] | None:
312312
msg = self._get_response(msg)
@@ -551,12 +551,12 @@ def _parse_time(self, msg: str) -> str:
551551
def _parse_temp(self, msg: str) -> float | None:
552552
if "NOT_FOUND" in msg:
553553
return None
554-
return float(msg.split("SIG:TEMP:")[-1].strip("K"))
554+
return float(msg.rsplit("SIG:TEMP:", maxsplit=1)[-1].strip("K"))
555555

556556
def _parse_pres(self, msg: str) -> float | None:
557557
if "NOT_FOUND" in msg:
558558
return None
559-
return float(msg.split("SIG:PRES:")[-1].strip("mB")) * 1e3
559+
return float(msg.rsplit("SIG:PRES:", maxsplit=1)[-1].strip("mB")) * 1e3
560560

561561
def _recv(self) -> str:
562562
return super()._recv().rstrip()
@@ -579,7 +579,7 @@ def _set_pump_state(self, pump: str, state: str) -> None:
579579
def _get_parser_pump_speed(self, msg: str) -> float | None:
580580
if "NOT_FOUND" in msg:
581581
return None
582-
return float(msg.split("SPD:")[-1].strip("Hz"))
582+
return float(msg.rsplit("SPD:", maxsplit=1)[-1].strip("Hz"))
583583

584584
def _add_temp_state(self) -> None:
585585
for i in range(1, 17):
@@ -599,7 +599,7 @@ def _set_temp_state(self, chan: str, state: str) -> None:
599599
def _get_parser_state(self, key: str, msg: str) -> str | None:
600600
if "NOT_FOUND" in msg:
601601
return None
602-
return msg.split(f"{key}:")[-1]
602+
return msg.rsplit(f"{key}:", maxsplit=1)[-1]
603603

604604

605605
Triton = OxfordTriton

src/qcodes/instrument_drivers/rigol/Rigol_DG1062.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,11 @@ def __init__(
209209
vals.Enum("INF", "MIN", "MAX", "HighZ"),
210210
),
211211
get_parser=(
212-
lambda value: "HighZ"
213-
if float(value) > RigolDG1062Channel.max_impedance
214-
else float(value)
212+
lambda value: (
213+
"HighZ"
214+
if float(value) > RigolDG1062Channel.max_impedance
215+
else float(value)
216+
)
215217
),
216218
set_parser=lambda value: "INF" if value == "HighZ" else value,
217219
)

src/qcodes/instrument_drivers/tektronix/AWG5014.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def __init__(
275275
get_cmd="AWGControl:SEQuencer:POSition?",
276276
set_cmd="SEQuence:JUMP:IMMediate {}",
277277
vals=vals.PermissiveInts(1),
278-
set_parser=lambda x: round(x),
278+
set_parser=round,
279279
)
280280
"""Parameter sequence_pos"""
281281

0 commit comments

Comments
 (0)