Skip to content

Commit

Permalink
Merge pull request #5806 from jenshnielsen/precommit_hooks_update
Browse files Browse the repository at this point in the history
upgrade precommit hooks to latest versions
  • Loading branch information
jenshnielsen authored Mar 8, 2024
2 parents 2403dab + 628cf25 commit 4b6c55a
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.2.2'
rev: 'v0.3.1'
hooks:
- id: ruff
types_or: [python, pyi, jupyter, toml]
Expand All @@ -21,7 +21,7 @@ repos:
- id: mixed-line-ending
args: ['--fix=no']
- repo: https://github.com/akaihola/darker
rev: 1.7.2
rev: 1.7.3
hooks:
- id: darker
- repo: https://github.com/gitleaks/gitleaks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,14 @@
"# Now the measured angles should be as we intended\n",
"theta_measured = i3d.theta_measured()\n",
"print(\n",
" \"2: Theta measured = {}. We see that the input theta of {} has been \"\n",
" \"remembered\".format(theta_measured, field_target_spherical[1])\n",
" f\"2: Theta measured = {theta_measured}. We see that the input theta of {field_target_spherical[1]} has been \"\n",
" \"remembered\"\n",
")\n",
"\n",
"phi_measured = i3d.phi_measured()\n",
"print(\n",
" \"2: Phi measured = {}. We see that the input phi of {} has been \"\n",
" \"remembered\".format(phi_measured, field_target_spherical[2])\n",
" f\"2: Phi measured = {phi_measured}. We see that the input phi of {field_target_spherical[2]} has been \"\n",
" \"remembered\"\n",
")"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@
"try:\n",
" gs.ramp_current(0.02, 0.001, 1)\n",
"except Exception:\n",
" print(\"Exception is correctly raised. Ramping is stopped at {} A because the\"\n",
" \" range is exceeded\".format(gs.current()))\n"
" print(f\"Exception is correctly raised. Ramping is stopped at {gs.current()} A because the\"\n",
" \" range is exceeded\")\n"
]
},
{
Expand Down
11 changes: 4 additions & 7 deletions src/qcodes/instrument_drivers/AlazarTech/dll_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,11 @@ def _check_error_code(

if return_code not in ERROR_CODES:
raise RuntimeError(
'unknown error {} from function {} with args: {}'.format(
return_code, func.__name__, argrepr))
f"unknown error {return_code} from function {func.__name__} with args: {argrepr}"
)
raise RuntimeError(
'error {}: {} from function {} with args: {}'.format(
return_code,
ERROR_CODES[ReturnCode(return_code)],
func.__name__,
argrepr))
f"error {return_code}: {ERROR_CODES[ReturnCode(return_code)]} from function {func.__name__} with args: {argrepr}"
)

return arguments

Expand Down
9 changes: 5 additions & 4 deletions src/qcodes/instrument_drivers/tektronix/AWG70000A.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,11 @@ def _set_fgfreq(self, channel: int, frequency: float) -> None:

# validate
if frequency < 1 or frequency > max_freq:
raise ValueError('Can not set channel {} frequency to {} Hz.'
' Maximum frequency for function type {} is {} '
'Hz, minimum is 1 Hz'.format(channel, frequency,
functype, max_freq))
raise ValueError(
f"Can not set channel {channel} frequency to {frequency} Hz."
f" Maximum frequency for function type {functype} is {max_freq} "
"Hz, minimum is 1 Hz"
)
else:
self.root_instrument.write(f'FGEN:CHANnel{channel}:'
f'FREQuency {frequency}')
Expand Down
4 changes: 1 addition & 3 deletions src/qcodes/instrument_drivers/yokogawa/GS200.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,7 @@ def _assert_mode(self, mode: ModeType) -> None:
"""
if self.source_mode.get_latest() != mode:
raise ValueError(
"Cannot get/set {} settings while in {} mode".format(
mode, self.source_mode.get_latest()
)
f"Cannot get/set {mode} settings while in {self.source_mode.get_latest()} mode"
)

def _set_source_mode(self, mode: ModeType) -> None:
Expand Down
4 changes: 1 addition & 3 deletions src/qcodes/parameters/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ def validate(self, *args: Any) -> None:

if len(args) != self._arg_count:
raise TypeError(
"{} called with {} args but requires {}".format(
func_name, len(args), self._arg_count
)
f"{func_name} called with {len(args)} args but requires {self._arg_count}"
)

validate_all(*zip(self._args, args), context="Function: " + func_name)
Expand Down
13 changes: 2 additions & 11 deletions src/qcodes/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,8 @@ def compare_dictionaries(

if not match:
value_err += (
'Value of "{}{}" ("{}", type"{}") not same as\n'
' "{}{}" ("{}", type"{}")\n\n'
).format(
dict_1_name,
path,
dict_1[k],
type(dict_1[k]),
dict_2_name,
path,
dict_2[k],
type(dict_2[k]),
f'Value of "{dict_1_name}{path}" ("{dict_1[k]}", type"{type(dict_1[k])}") not same as\n'
f' "{dict_2_name}{path}" ("{dict_2[k]}", type"{type(dict_2[k])}")\n\n'
)

for k in dict_2.keys():
Expand Down
4 changes: 1 addition & 3 deletions src/qcodes/validators/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,7 @@ def validate(self, value: numbertypes, context: str = "") -> None:
raise ValueError(f"{value} is not a multiple" + f" of {self._divisor}.")

def __repr__(self) -> str:
repr_str = "<PermissiveMultiples, Multiples of {} to within {}>".format(
self._divisor, self._precision
)
repr_str = f"<PermissiveMultiples, Multiples of {self._divisor} to within {self._precision}>"
return repr_str

is_numeric = True
Expand Down

0 comments on commit 4b6c55a

Please sign in to comment.