From a760e0b18936b21ca8ac34d3a38ef7dd2f217f66 Mon Sep 17 00:00:00 2001 From: Shashank P <142999380+u625355@users.noreply.github.com> Date: Mon, 9 Sep 2024 21:21:11 +0530 Subject: [PATCH] fix: Resolved some security issues flagged by CodeQL (#4) * Update README.md with readthedocs link Signed-off-by: Shashank P <142999380+u625355@users.noreply.github.com> * Updated documentation status for stable version. Signed-off-by: Shashank P <142999380+u625355@users.noreply.github.com> * fix: updated tekhsi_connect.py by removing multiple import errors. Removed duplicate imports. Prefixed unused term for unused global variables. Signed-off-by: Shashank P <142999380+u625355@users.noreply.github.com> * fix: optimized imports in test_client.py Signed-off-by: Shashank P <142999380+u625355@users.noreply.github.com> * fix: replaced unused variable with underscore in simple_read.py Signed-off-by: Shashank P <142999380+u625355@users.noreply.github.com> * fix: removed unused variable in tek_hsi_connect.py Signed-off-by: Shashank P <142999380+u625355@users.noreply.github.com> * fix: Updated macros.py to remove black formatting on basic_usage Signed-off-by: Shashank P <142999380+u625355@users.noreply.github.com> --------- Signed-off-by: Shashank P <142999380+u625355@users.noreply.github.com> --- README.md | 2 +- docs/macros.py | 4 +++- examples/simple_read.py | 2 +- src/tekhsi/tek_hsi_connect.py | 4 +--- tests/test_client.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f7e4620..be9bcda 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ | **Testing** | [![Code testing status](https://github.com/tektronix/TekHSI/actions/workflows/test-code.yml/badge.svg?branch=main)](https://github.com/tektronix/TekHSI/actions/workflows/test-code.yml) [![Docs testing status](https://github.com/tektronix/TekHSI/actions/workflows/test-docs.yml/badge.svg?branch=main)](https://github.com/tektronix/TekHSI/actions/workflows/test-docs.yml) [![Coverage status](https://codecov.io/gh/tektronix/TekHSI/branch/main/graph/badge.svg)](https://codecov.io/gh/tektronix/TekHSI) | | **Code Quality** | [![CodeQL status](https://github.com/tektronix/TekHSI/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/tektronix/TekHSI/actions/workflows/codeql-analysis.yml) [![CodeFactor grade](https://www.codefactor.io/repository/github/tektronix/TekHSI/badge)](https://www.codefactor.io/repository/github/tektronix/TekHSI) [![pre-commit status](https://results.pre-commit.ci/badge/github/tektronix/TekHSI/main.svg)](https://results.pre-commit.ci/latest/github/tektronix/TekHSI/main) | | **Package** | [![PyPI: Package status](https://img.shields.io/pypi/status/TekHSI?logo=pypi)](https://pypi.org/project/TekHSI/) [![PyPI: Latest release version](https://img.shields.io/pypi/v/TekHSI?logo=pypi)](https://pypi.org/project/TekHSI/) [![PyPI: Supported Python versions](https://img.shields.io/pypi/pyversions/TekHSI?logo=python)](https://pypi.org/project/TekHSI/) [![PyPI: Downloads](https://pepy.tech/badge/TekHSI)](https://pepy.tech/project/TekHSI) [![License: Apache 2.0](https://img.shields.io/pypi/l/TekHSI)](https://github.com/tektronix/TekHSI/blob/main/LICENSE.md) [![Package build status](https://github.com/tektronix/TekHSI/actions/workflows/package-build.yml/badge.svg?branch=main)](https://github.com/tektronix/TekHSI/actions/workflows/package-build.yml) [![PyPI upload status](https://github.com/tektronix/TekHSI/actions/workflows/package-release.yml/badge.svg?branch=main)](https://github.com/tektronix/TekHSI/actions/workflows/package-release.yml) | -| **Documentation** | [![ReadtheDocs Status](https://img.shields.io/readthedocs/TekHSI/stable?logo=readthedocs)](https://TekHSI.readthedocs.io/stable) | +| **Documentation** | [![ReadtheDocs Status](https://img.shields.io/readthedocs/TekHSI/stable?logo=readthedocs)](https://tekhsi.readthedocs.io/stable) | | **Code Style** | [![Test style: pytest](https://img.shields.io/badge/test%20style-pytest-blue)](https://github.com/pytest-dev/pytest) [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-black)](https://docs.astral.sh/ruff/formatter/) [![Docstring style: google](https://img.shields.io/badge/docstring%20style-google-tan)](https://google.github.io/styleguide/pyguide.html) | | **Linting** | [![pre-commit enabled](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit) [![Docstring formatter: docformatter](https://img.shields.io/badge/docstring%20formatter-docformatter-tan)](https://github.com/PyCQA/docformatter)[![Linter: pylint](https://img.shields.io/badge/linter-pylint-purple)](https://github.com/pylint-dev/pylint) | diff --git a/docs/macros.py b/docs/macros.py index 96f604f..e3ec347 100644 --- a/docs/macros.py +++ b/docs/macros.py @@ -20,7 +20,9 @@ ), "index.md": ((" Scopes ", r" [Scopes](default:Scope) "),), } -FILES_TO_REMOVE_BLACK_FORMATTER_DISABLE_COMMENT = {} +FILES_TO_REMOVE_BLACK_FORMATTER_DISABLE_COMMENT = { + "basic_usage.md", +} #################################################################################################### diff --git a/examples/simple_read.py b/examples/simple_read.py index 5dd58ad..ea5ee6c 100644 --- a/examples/simple_read.py +++ b/examples/simple_read.py @@ -40,7 +40,7 @@ ax.set_ylim(min_val - extra, max_val + extra) ax.set_xlim(np.min(horizontal_data), np.max(horizontal_data)) -(line,) = ax.plot(horizontal_data, vertical_data) +(_,) = ax.plot(horizontal_data, vertical_data) # Display the plot plt.show() diff --git a/src/tekhsi/tek_hsi_connect.py b/src/tekhsi/tek_hsi_connect.py index d391935..9849826 100644 --- a/src/tekhsi/tek_hsi_connect.py +++ b/src/tekhsi/tek_hsi_connect.py @@ -7,7 +7,6 @@ from atexit import register from enum import Enum -from contextlib import contextmanager from typing import List, Optional, Dict @@ -214,7 +213,7 @@ def verbose(self, value: bool): ################################################################################################ # Context Manager Methods ################################################################################################ - @contextmanager + @contextlib.contextmanager def access_data(self, on: AcqWaitOn = AcqWaitOn.NewData, after: float = -1): """Grants access to data. @@ -650,7 +649,6 @@ def _read_waveform(self, header: WaveformHeader): ) sample_index = 0 - data_size = header.sourcewidth request = WaveformRequest(sourcename=header.sourcename, chunksize=self.chunksize) response_iterator = self.native.GetWaveform(request) dt = None diff --git a/tests/test_client.py b/tests/test_client.py index f0d7f41..353653a 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -6,7 +6,7 @@ import numpy as np import pytest -from tm_data_types import AnalogWaveform, IQWaveform, DigitalWaveform, Waveform +from tm_data_types import AnalogWaveform, IQWaveform, DigitalWaveform from tekhsi.helpers import print_with_timestamp from tekhsi.tek_hsi_connect import TekHSIConnect, AcqWaitOn