Skip to content

Implement remaining ruff 0.16 lints - #8368

Draft
jenshnielsen wants to merge 7 commits into
microsoft:mainfrom
jenshnielsen:jenshnielsen/ruff_016_2
Draft

Implement remaining ruff 0.16 lints#8368
jenshnielsen wants to merge 7 commits into
microsoft:mainfrom
jenshnielsen:jenshnielsen/ruff_016_2

Conversation

@jenshnielsen

Copy link
Copy Markdown
Collaborator

No description provided.

jenshnielsen and others added 7 commits July 31, 2026 15:18
Instrument driver modules that are part of the public qcodes namespace
cannot be renamed without breaking user code, so they are exempted via
lint.pep8-naming.extend-ignore-names. Test modules with invalid names
are renamed to lower case.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8be348f8-5322-4e8d-b75a-3d00baca556f
Update the Contributor guide and the "Creating Instrument Drivers"
example notebook to state that driver modules should be named using
lower case snake_case, with vendor/model capitalization only in the
class name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8be348f8-5322-4e8d-b75a-3d00baca556f
Rename the private module level loggers `_LOG` to `_LOGGER` so that ruff
recognises them as loggers, switch several catch-all handlers to
`Logger.exception` so that the traceback is logged, narrow the exceptions
caught in the Triton driver, chain the exception raised by AWG70000A and
explicitly mark the remaining intentional catch-alls with `noqa: BLE001`.
The example notebooks deliberately catch broad exceptions to demonstrate
that an operation is rejected, so `docs/*` ignores the rule.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8be348f8-5322-4e8d-b75a-3d00baca556f
`Station.add_component` now logs the traceback when snapshotting a
component fails rather than silently swallowing it. The test cleanup
fixture uses `contextlib.suppress`. The remaining silent handlers are in
teardown paths (`Instrument.__del__` and `strip_attrs`) that must never
raise and must not log since the logging machinery may already be torn
down, so they are explicitly marked as intentional.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8be348f8-5322-4e8d-b75a-3d00baca556f
Replace the bare `Exception` raised in a number of drivers with a
specific builtin exception: `ValueError` for invalid arguments,
`RuntimeError` for using the instrument in an unsupported state and
`NotImplementedError` for the unimplemented AlazarTech ATS acquisition
modes. All of these are subclasses of `Exception` so existing code that
catches `Exception` is unaffected.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8be348f8-5322-4e8d-b75a-3d00baca556f
Now that the drivers raise specific exceptions, several of the handlers
added when enabling BLE001 can be narrowed to the exceptions that the
guarded code actually raises: `VisaIOError` when waiting for the AWG5014,
`OSError`/`VisaIOError` when reading an Infiniium screenshot, the
`OSError` raised by `check_for_error` when aborting a SignalHound
acquisition and the subprocess/json errors when querying pip. The
remaining blind handlers guard user supplied validators, arbitrary module
imports and teardown paths, so their `noqa` comments now state why.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8be348f8-5322-4e8d-b75a-3d00baca556f
New code should raise `TypeError` when rejecting a value because of its
type. The 46 existing type checks that raise `ValueError` or
`RuntimeError` are deliberately left unchanged and marked with
`noqa: TRY004`: `TypeError` is not a subclass of either, so changing them
would break user code that catches the current exception. `RUF100` will
flag the `noqa` as unused if such a call site is ever changed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8be348f8-5322-4e8d-b75a-3d00baca556f
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 46.61017% with 63 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.10%. Comparing base (355ba4b) to head (0569625).
⚠️ Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
...ent_drivers/signal_hound/SignalHound_USB_SA124B.py 0.00% 7 Missing ⚠️
src/qcodes/dataset/database_extract_runs.py 73.33% 4 Missing ⚠️
...codes/instrument_drivers/oxford/MercuryiPS_VISA.py 0.00% 4 Missing ⚠️
src/qcodes/dataset/data_set.py 0.00% 3 Missing ⚠️
src/qcodes/instrument_drivers/AlazarTech/ATS.py 0.00% 3 Missing ⚠️
src/qcodes/instrument_drivers/tektronix/AWG5014.py 25.00% 3 Missing ⚠️
src/qcodes/extensions/_refactor.py 50.00% 2 Missing ⚠️
...codes/instrument_drivers/Keithley/Keithley_2450.py 0.00% 2 Missing ⚠️
...rc/qcodes/instrument_drivers/Keysight/Infiniium.py 0.00% 2 Missing ⚠️
...odes/instrument_drivers/stanford_research/SR830.py 0.00% 2 Missing ⚠️
... and 28 more
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8368   +/-   ##
=======================================
  Coverage   71.09%   71.10%           
=======================================
  Files         305      305           
  Lines       31934    31933    -1     
=======================================
  Hits        22705    22705           
+ Misses       9229     9228    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant