Add doctests#8072
Open
jenshnielsen wants to merge 8 commits intomicrosoft:mainfrom
Open
Conversation
DotDict.__getattr__ was propagating KeyError from __getitem__ when accessing missing attributes. Python's attribute protocol requires AttributeError for missing attributes, otherwise hasattr() and inspect.unwrap() break. This caused --doctest-modules to fail with 'KeyError: __wrapped__' when collecting test files.
- Convert illustrative docstring examples from >>> syntax to .. code-block:: python to prevent them being parsed as doctests - Add # doctest: +SKIP for simple single-line illustrative examples - Fix _SetParamContext docstring whitespace inconsistency - Add conftest.py to ignore instrument drivers requiring optional dependencies (gclib, clr/pythonnet, pywin32) during collection
Convert 14 examples from .. code-block:: python back to executable >>> doctest syntax in cases where no hardware or complex external state is needed: - validators: MultiType, MultiTypeOr, MultiTypeAnd - field_vector: set_vector, set_component - parameter_base: set_to, restore_at_exit - parameter: sweep - sweep_values: make_sweep - stahl: chain - threading_utils: RespondingThread - logger: LogCapture - lakeshore_base: _get_sum_terms - keysight_e4980a: KeysightE4980AMeasurementPair 5 examples remain as skipped or code-blocks because they require instruments, database infrastructure, or produce complex output (Config.add, guids_from_list_str, DataSaver.add_result, Instrument.close_all, partial_with_docstring).
Dynamically detect deprecated driver alias modules (those containing 'module is deprecated') and exclude them from doctest collection. This eliminates 14 QCoDeSDeprecationWarning warnings that were triggered just by importing these modules during pytest --doctest-modules.
Replace jumanjihouse/pre-commit-hooks (requires Docker or system shellcheck) with shellcheck-py/shellcheck-py which provides a pip-installable shellcheck binary for macOS, Linux, and Windows.
jenshnielsen
commented
Apr 28, 2026
| >>> get_sum_terms(terms, 96) | ||
| ... [64, 32] # This is correct because 96=64+32 | ||
| >>> [int(x) for x in LakeshoreBaseSensorChannel._get_sum_terms(terms, 96)] | ||
| [64, 32] |
Collaborator
Author
There was a problem hiding this comment.
Readd comment
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8072 +/- ##
==========================================
+ Coverage 70.59% 70.60% +0.01%
==========================================
Files 333 334 +1
Lines 32490 32508 +18
==========================================
+ Hits 22936 22952 +16
- Misses 9554 9556 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Convert several inline examples to doctests and execute these in CI