Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CodeQL and Codecov issues #11

Merged
merged 15 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/assign-reviewers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ jobs:
- name: Assign Reviewers
uses: rowi1de/[email protected]
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
10 changes: 7 additions & 3 deletions .github/workflows/test-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ MANIFEST
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.coverage*
.cache
coverage.xml
*.cover
Expand Down
11 changes: 11 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
coverage:
status:
project:
default:
target: 100%
threshold: 0%
patch:
default:
target: 100%
threshold: 0%
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/tm_devices/device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 0 additions & 1 deletion src/tm_devices/helpers/constants_and_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 2 additions & 9 deletions src/tm_devices/helpers/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -55,8 +50,6 @@
"65": "SMU",
"37": "SS",
}
_MODEL_BEGINNINGS_TO_COMBINE: Set[str] = set()
_SPECIFIC_DRIVER_SET: Set[str] = set()


####################################################################################################
Expand All @@ -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"
)
Expand Down