diff --git a/.github/workflows/assign-reviewers.yml b/.github/workflows/assign-reviewers.yml index 9237afe6..429dc29e 100644 --- a/.github/workflows/assign-reviewers.yml +++ b/.github/workflows/assign-reviewers.yml @@ -10,5 +10,9 @@ jobs: - name: Assign Reviewers uses: rowi1de/auto-assign-review-teams@v1.1.3 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + # If this job ever starts failing, the most likely reason is that this secret is no + # longer valid. This secret needs to be a Personal Access Token (Classic) with the + # public_repo and read:org permissions. It also needs to be from an account that is + # part of the tektronix GitHub organization. + repo-token: ${{ secrets.ASSIGN_REVIEWERS_TOKEN }} teams: tm-devices-maintainers diff --git a/.github/workflows/test-code.yml b/.github/workflows/test-code.yml index 5f48e9fb..2c739aaf 100644 --- a/.github/workflows/test-code.yml +++ b/.github/workflows/test-code.yml @@ -37,7 +37,9 @@ jobs: if: '!cancelled()' with: name: artifact_${{ matrix.platform }}_${{ matrix.python-version }}_tests_and_linting - path: .results_*/** + path: | + .results_*/** + .coverage* # Quick testing with coverage (no linting) test-fast: runs-on: ${{ matrix.os_name }}-latest @@ -62,12 +64,14 @@ jobs: if: '!cancelled()' with: name: artifact_${{ matrix.os_name }}_tests - path: .results_*/** + path: | + .results_*/** + .coverage* # TODO: look into using https://github.com/mikepenz/action-junit-report for a junit report - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: - files: ./.coverage.tests + files: ./.coverage_tests.xml name: codecov-${{ matrix.os_name }} fail_ci_if_error: true # Check that all jobs passed diff --git a/.gitignore b/.gitignore index bd2692a8..aed18420 100644 --- a/.gitignore +++ b/.gitignore @@ -47,8 +47,7 @@ MANIFEST htmlcov/ .tox/ .nox/ -.coverage -.coverage.* +.coverage* .cache coverage.xml *.cover diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..05f29d9f --- /dev/null +++ b/codecov.yml @@ -0,0 +1,11 @@ +--- +coverage: + status: + project: + default: + target: 100% + threshold: 0% + patch: + default: + target: 100% + threshold: 0% diff --git a/examples/source_measure_units/2400/smu_2450_linear_sweep_current.py b/examples/source_measure_units/2400/smu_2450_linear_sweep_current.py index ba52c698..e7785d0f 100644 --- a/examples/source_measure_units/2400/smu_2450_linear_sweep_current.py +++ b/examples/source_measure_units/2400/smu_2450_linear_sweep_current.py @@ -47,7 +47,7 @@ # Run trigger model and wait for it to complete smu2450.commands.trigger.model.initiate() - throw_away = smu2450.commands.status.operation.condition # throw away first read of status byte + _ = smu2450.commands.status.operation.condition # throw away first read of status byte is_sweeping = int(smu2450.commands.status.operation.condition.rstrip()) while is_sweeping: diff --git a/examples/source_measure_units/2400/smu_2461_1kw_pulsing.py b/examples/source_measure_units/2400/smu_2461_1kw_pulsing.py index 9edccae4..2c6ac363 100644 --- a/examples/source_measure_units/2400/smu_2461_1kw_pulsing.py +++ b/examples/source_measure_units/2400/smu_2461_1kw_pulsing.py @@ -63,7 +63,7 @@ wait = 0.2 # pylint: disable=invalid-name smu2461.commands.trigger.model.initiate() # Wait for the measurements to complete. waitcomplete() - garbage = smu2461.commands.status.operation.condition # throw away first read of status byte + _ = smu2461.commands.status.operation.condition # throw away first read of status byte while is_sweeping: sleep(wait := wait * 1.1) diff --git a/examples/source_measure_units/2400/smu_2461_pulse_sweep_i_digitize_v.py b/examples/source_measure_units/2400/smu_2461_pulse_sweep_i_digitize_v.py index d9f3924e..3cdc3bad 100644 --- a/examples/source_measure_units/2400/smu_2461_pulse_sweep_i_digitize_v.py +++ b/examples/source_measure_units/2400/smu_2461_pulse_sweep_i_digitize_v.py @@ -84,7 +84,7 @@ # Run trigger model and wait for it to complete smu2461.commands.trigger.model.initiate() # waitcomplete - garbage = smu2461.commands.status.operation.condition # throw away first read of status byte + _ = smu2461.commands.status.operation.condition # throw away first read of status byte while is_sweeping: operation_condition_register = int(smu2461.commands.status.operation.condition.rstrip()) diff --git a/examples/source_measure_units/2400/smu_2461_pulse_sweep_trigger_out.py b/examples/source_measure_units/2400/smu_2461_pulse_sweep_trigger_out.py index cf40609b..156dc5f7 100644 --- a/examples/source_measure_units/2400/smu_2461_pulse_sweep_trigger_out.py +++ b/examples/source_measure_units/2400/smu_2461_pulse_sweep_trigger_out.py @@ -185,7 +185,7 @@ def pulse_delay_calc(pulse_width: str) -> float: wait = 1 # pylint: disable=invalid-name smu2461.commands.trigger.model.initiate() # Wait for the measurements to complete. waitcomplete() - garbage = smu2461.commands.status.operation.condition # throw away first read of status byte + _ = smu2461.commands.status.operation.condition # throw away first read of status byte while is_sweeping: sleep(wait := wait * 1.1) diff --git a/examples/source_measure_units/2400/smu_2470_insulation_resistance.py b/examples/source_measure_units/2400/smu_2470_insulation_resistance.py index 4f05c9d1..e4beaf2a 100644 --- a/examples/source_measure_units/2400/smu_2470_insulation_resistance.py +++ b/examples/source_measure_units/2400/smu_2470_insulation_resistance.py @@ -38,7 +38,7 @@ smu2470.commands.trigger.model.initiate() # Wait for the measurements to complete. waitcomplete() - garbage = smu2470.commands.status.operation.condition # throw away first read of status byte + _ = smu2470.commands.status.operation.condition # throw away first read of status byte while is_sweeping: operation_condition_register = int(smu2470.commands.status.operation.condition.rstrip()) diff --git a/examples/source_measure_units/2400/smu_2470_mosfet_leakage.py b/examples/source_measure_units/2400/smu_2470_mosfet_leakage.py index 70548c5b..92afb102 100644 --- a/examples/source_measure_units/2400/smu_2470_mosfet_leakage.py +++ b/examples/source_measure_units/2400/smu_2470_mosfet_leakage.py @@ -37,7 +37,7 @@ smu2470.commands.trigger.model.initiate() # Wait for the measurements to complete. waitcomplete() - garbage = smu2470.commands.status.operation.condition # throw away first read of status byte + _ = smu2470.commands.status.operation.condition # throw away first read of status byte while is_sweeping: operation_condition_register = int(smu2470.commands.status.operation.condition.rstrip()) diff --git a/pyproject.toml b/pyproject.toml index 5253c01d..4d9c4537 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -395,7 +395,6 @@ deps = poetry setenv = DOC_PYTHON_VERSION = python3.11 # Keep this in sync with .readthedocs.yml and any CI scripts - COVERAGE_FILE = .coverage.{envname} # Skip pre-commit checks that are explicitly performed by tox SKIP = black,docformatter,ruff,pylint,pyright,pyright-verifytypes,pyroma commands_pre = @@ -410,7 +409,7 @@ commands = !tests: pyright --verifytypes tm_devices --ignoreexternal !tests: pyroma . !tests: pre-commit run --all-files --show-diff-on-failure - pytest -vv -k "not test_docs" --showlocals --cov --junitxml={tox_root}/.results_{envname}/results.xml --cov-report=term --cov-report=html:{tox_root}/.results_{envname}/html --self-contained-html --html={tox_root}/.results_{envname}/results.html + pytest -vv -k "not test_docs" --showlocals --cov --junitxml={tox_root}/.results_{envname}/results.xml --cov-report=term --cov-report=xml:{tox_root}/.coverage_{envname}.xml --cov-report=html:{tox_root}/.results_{envname}/html --self-contained-html --html={tox_root}/.results_{envname}/results.html [testenv:tests] basepython = python diff --git a/src/tm_devices/device_manager.py b/src/tm_devices/device_manager.py index edace027..8a9388dd 100644 --- a/src/tm_devices/device_manager.py +++ b/src/tm_devices/device_manager.py @@ -1426,6 +1426,4 @@ def __set_options(self, verbose: bool) -> None: self.__visa_library = visa_library else: self.__visa_library = "" - else: - self.__visa_library = self.__visa_library self.verbose_visa = bool(self.__config.options.verbose_visa) diff --git a/src/tm_devices/helpers/constants_and_dataclasses.py b/src/tm_devices/helpers/constants_and_dataclasses.py index 7579182d..a97157d5 100644 --- a/src/tm_devices/helpers/constants_and_dataclasses.py +++ b/src/tm_devices/helpers/constants_and_dataclasses.py @@ -503,7 +503,6 @@ def __str__(self) -> str: # USBTMC configuration defines _TEKTRONIX_USBTMC_VENDOR_ID: Final = "0x0699" _KEITHLEY_USBTMC_VENDOR_ID: Final = "0x05E6" -_USBTMC_UNKNOWN_MODEL: Final = "Unknown" USB_MODEL_ID_LOOKUP: Final[Mapping[str, USBTMCConfiguration]] = MappingProxyType( { SupportedModels.MDO3K.value: USBTMCConfiguration( diff --git a/src/tm_devices/helpers/functions.py b/src/tm_devices/helpers/functions.py index ccc6b35a..9db49d79 100644 --- a/src/tm_devices/helpers/functions.py +++ b/src/tm_devices/helpers/functions.py @@ -10,9 +10,8 @@ import time import warnings -from contextlib import redirect_stderr, redirect_stdout from enum import EnumMeta -from typing import Any, Dict, Optional, Set, Tuple, Type +from typing import Any, Dict, Optional, Tuple, Type from check4updates import check_and_prompt # type: ignore from packaging.version import InvalidVersion, Version @@ -41,10 +40,6 @@ #################################################################################################### # Private Constants #################################################################################################### -_HOSTNAME_REGEX = re.compile( - r"^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*" - r"([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$" -) _VISA_SYSTEM_DETAILS: Dict[str, Any] = pyvisa_util.get_system_details() _KEITHLEY_2_CHAR_MODEL_LOOKUP = { "24": "SMU", @@ -55,8 +50,6 @@ "65": "SMU", "37": "SS", } -_MODEL_BEGINNINGS_TO_COMBINE: Set[str] = set() -_SPECIFIC_DRIVER_SET: Set[str] = set() #################################################################################################### @@ -71,7 +64,7 @@ def check_for_update(package_name: str = PACKAGE_NAME) -> None: starting_dir = os.getcwd() try: # Check for package updates, set the interval to zero to always check. - with redirect_stdout(None), redirect_stderr(None): + with contextlib.redirect_stdout(None), contextlib.redirect_stderr(None): result = check_and_prompt( package_name, remind_delay=0, online_check_interval=0, mock_user_input="2" )