Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Please include a summary of the changes and any links to related issues. Please also include relevant motivation and context.

Addresses #\< fill in issue number here >
Addresses #< fill in issue number here >

## Types of changes

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-api-for-breaking-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ on:
branches: [main]
jobs:
check-api-for-breaking-changes:
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-check-api-for-breaking-changes.yml@v1.6.2
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-check-api-for-breaking-changes.yml@v1.7.5
with:
package-name: tekhsi # griffe requires the package name in lowercase
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- cron: 17 16 * * 4
jobs:
analyze:
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-codeql-analysis.yml@v1.6.2
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-codeql-analysis.yml@v1.7.5
with:
languages-array: '["python", "javascript"]'
codeql-queries: security-extended,security-and-quality
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/enforce-community-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ on:
branches: [main]
jobs:
enforce-community-standards:
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-enforce-community-standards.yml@v1.6.2
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-enforce-community-standards.yml@v1.7.5
4 changes: 2 additions & 2 deletions .github/workflows/package-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
package-build:
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-package-build.yml@v1.6.2
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-package-build.yml@v1.7.5
with:
package-name: tekhsi
python-versions-array: '["3.8", "3.9", "3.10", "3.11", "3.12"]' # when updating this, make sure to update all workflows that use this strategy
python-versions-array: '["3.9", "3.10", "3.11", "3.12", "3.13"]' # when updating this, make sure to update all workflows that use this strategy
operating-systems-array: '["ubuntu", "windows", "macos"]'
permissions:
contents: read
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ concurrency:
group: pypi
jobs:
package-release:
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-package-release.yml@v1.6.2
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-package-release.yml@v1.7.5
with:
package-name: TekHSI
repo-name: tektronix/TekHSI
commit-user-name: ${{ vars.TEK_OPENSOURCE_NAME }}
commit-user-email: ${{ vars.TEK_OPENSOURCE_EMAIL }}
release-level: ${{ inputs.release-level }}
build-and-publish-python-package: true
python-versions-array: '["3.8", "3.9", "3.10", "3.11", "3.12"]' # when updating this, make sure to update all workflows that use this strategy
python-versions-array: '["3.9", "3.10", "3.11", "3.12", "3.13"]' # when updating this, make sure to update all workflows that use this strategy
operating-systems-array: '["ubuntu", "windows", "macos"]'
previous-changelog-filepath: python_semantic_release_templates/.previous_changelog_for_template.md
previous-release-notes-filepath: python_semantic_release_templates/.previous_release_notes_for_template.md
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/package-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ concurrency:
group: pypi
jobs:
package-testpypi:
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-package-testpypi.yml@v1.6.2
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-package-testpypi.yml@v1.7.5
with:
package-name: TekHSI
repo-name: tektronix/TekHSI
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-api-comparison.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
types: [completed]
jobs:
publish-api-comparison:
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-publish-api-comparison.yml@v1.6.2
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-publish-api-comparison.yml@v1.7.5
permissions:
checks: write
pull-requests: write
2 changes: 1 addition & 1 deletion .github/workflows/publish-test-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
types: [completed]
jobs:
publish-test-results:
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-publish-test-results.yml@v1.6.2
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-publish-test-results.yml@v1.7.5
with:
operating-systems-array: '["ubuntu", "windows", "macos"]'
permissions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sbom-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
types: [published]
jobs:
sbom-scan:
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-sbom-scan.yml@v1.6.2
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-sbom-scan.yml@v1.7.5
permissions:
security-events: write
contents: write
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
test-code:
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-test-code.yml@v1.6.2
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-test-code.yml@v1.7.5
with:
repo-name: tektronix/TekHSI
operating-systems-array: '["ubuntu", "windows", "macos"]'
python-versions-array: '["3.8", "3.9", "3.10", "3.11", "3.12"]' # when updating this, make sure to update all workflows that use this strategy
python-versions-array: '["3.9", "3.10", "3.11", "3.12", "3.13"]' # when updating this, make sure to update all workflows that use this strategy
upload-to-codecov: true
secrets:
codecov-token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/test-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
test-docs:
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-test-docs.yml@v1.6.2
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-test-docs.yml@v1.7.5
with:
node-version: 20 # The node version needs to stay in sync with .readthedocs.yml
python-version: '3.11' # This needs to stay in sync with .readthedocs.yml and the tox config in pyproject.toml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ on:
jobs:
update-python-and-pre-commit-dependencies:
if: ${{ github.actor == 'dependabot[bot]' && contains(github.head_ref, '/pip/') }}
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-update-python-and-pre-commit-dependencies.yml@v1.6.2
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-update-python-and-pre-commit-dependencies.yml@v1.7.5
with:
commit-user-name: ${{ vars.TEK_OPENSOURCE_NAME }}
commit-user-email: ${{ vars.TEK_OPENSOURCE_EMAIL }}
update-pre-commit: true
run-pre-commit: true
pre-commit-hook-skip-list: pylint,pyright,pyright-verifytypes,pyroma,poetry-audit
pre-commit-repo-update-skip-list: https://github.com/executablebooks/mdformat,https://github.com/pappasam/toml-sort
pre-commit-hook-skip-list: pylint,pyright,pyright-verifytypes,pyroma,poetry-lock,poetry-audit,poetry-check
export-dependency-groups: docs,tests
permissions:
contents: write
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ docs/_autoapi/
docs/reference/
_readthedocs/
*site*/
*.inv

# Distribution / packaging
.Python build/
Expand All @@ -41,6 +42,7 @@ python_semantic_release_templates/.previous_release_notes_for_template.md
pip-log.txt
pip-delete-this-directory.txt
*.log
*.dat

# Unit test / coverage reports
htmlcov/
Expand All @@ -54,6 +56,7 @@ coverage.xml
*.cover
*.py,cover
.results*/
.dist*/
.hypothesis/
tests/generated_**/*

Expand Down
53 changes: 31 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ ci:
autofix_prs: false
autoupdate_schedule: quarterly
skip:
- check-poetry
- pylint
# - pyright
# - pyright-verifytypes
- pyroma
- poetry-lock
- poetry-audit
- poetry-check
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
Expand Down Expand Up @@ -39,20 +40,20 @@ repos:
- id: remove-tabs
- id: forbid-tabs
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: cb3c2be894b151dff143b1baf6acbd55f2b7faed # frozen: 0.30.0
rev: 54da05914997e6b04e4db33ed6757d744984c68b # frozen: 0.33.2
hooks:
- id: check-readthedocs
- id: check-dependabot
- id: check-github-actions
- id: check-github-workflows
args: [--verbose]
- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
rev: 060504a904804d5314d4db5dd12aa8751717ffc7 # frozen: v1.7.4.20
rev: a185be0fd5b45112845b700d91b81050c75579e2 # frozen: v1.7.7.23
hooks:
- id: actionlint
additional_dependencies: [pyflakes, shellcheck-py]
- repo: https://github.com/commitizen-tools/commitizen
rev: 76efedd776e04c9604a1d54fef389a292cbf7768 # frozen: v4.0.0
rev: c710c9f541ae452547fdce5c360929f007ec4867 # frozen: v4.8.3
hooks:
- id: commitizen
stages: [commit-msg]
Expand All @@ -65,13 +66,12 @@ repos:
hooks:
- id: curlylint
- repo: https://github.com/executablebooks/mdformat
rev: 08fba30538869a440b5059de90af03e3502e35fb # frozen: 0.7.17
rev: ff29be1a1ba8029d9375882aa2c812b62112a593 # frozen: 0.7.22
hooks:
- id: mdformat
args: [--number, --end-of-line, keep, --ignore-missing-references]
additional_dependencies:
- setuptools # This is required since Python 3.12 no longer installs setuptools by default in virtual environments
- mdformat-admon
- mdformat-black # This may need to be updated/removed in the future once ruff supports formatting python code blocks in markdown
- mdformat-beautysh
- mdformat-config
Expand All @@ -86,12 +86,8 @@ repos:
- mdformat-toc
- mdformat-web
- mdformat-wikilink
- repo: https://gitlab.com/smop/pre-commit-hooks
rev: df034f88cf92b394e6f00a78fa97a2aa4e270e60 # frozen: v1.0.0
hooks:
- id: check-poetry
- repo: https://github.com/pappasam/toml-sort
rev: b9b6210da457c38122995e434b314f4c4a4a923e # frozen: v0.23.1
rev: 4ec24891e200ae663aa2a7cecd19516080777133 # frozen: v0.24.2
hooks:
- id: toml-sort-fix
- repo: local
Expand Down Expand Up @@ -124,23 +120,36 @@ repos:
pass_filenames: false
always_run: true
args: [., --min=10]
- id: poetry-lock
name: poetry-lock
entry: poetry lock
language: system
pass_filenames: false
always_run: true
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$
- id: poetry-audit
name: poetry-audit
entry: poetry
entry: poetry audit
language: system
types: [toml]
pass_filenames: false
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$
always_run: true
args: [audit, --json, --ignore-code=CVE-2019-8341]
args: [--json, --ignore-code=CVE-2019-8341]
- id: poetry-check
name: poetry-check
entry: poetry check
language: system
pass_filenames: false
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$
# args: [--strict] # TODO: enable this when poetry can be updated to v2+
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 859e42ab7d54544f32d4f73bbc2136a7d9094f54 # frozen: v0.8.1
rev: 0b19ef1fd6ad680ed7752d6daba883ce1265a6de # frozen: v0.12.2
hooks:
- id: ruff
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
# TODO: Re-enable this once https://github.com/PyCQA/docformatter/issues/293 is resolved
# - repo: https://github.com/PyCQA/docformatter
# rev: dfefe062799848234b4cd60b04aa633c0608025e # frozen: v1.7.5
# hooks:
# - id: docformatter
# additional_dependencies: [tomli]
- repo: https://github.com/PyCQA/docformatter
rev: e73b8ba0c1316be565983236c72e653ad44e6b66 # frozen: v1.7.7
hooks:
- id: docformatter
additional_dependencies: [tomli]
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ Valid subsections within a version are:

Things to be included in the next release go here.

### Removed

- Python 3.8 support has been removed from the package. The minimum supported version is now Python 3.9.

### Added

- Added support for Python 3.13.

- Added an installation section to the main README.

### Changed
Expand Down Expand Up @@ -79,7 +85,7 @@ Things to be included in the next release go here.
- tests: Update test_client.py for tests to run efficiently on tox. ([#8](https://github.com/tektronix/TekHSI/pull/8))
- fix: Resolved some security issues flagged by CodeQL ([#4](https://github.com/tektronix/TekHSI/pull/4))
- build: Update dependencies to temporarily use the GitHub repo for tm_data_types ([#2](https://github.com/tektronix/TekHSI/pull/2))
- fix: Updated line endings in known_words.txt ([#1](https://github.com/tektronix/TekHSI/pull/1))
- fix: Updated line endings in known_words.txt ([#1](https://github.com/tektronix/TekHSI/pull/1))

### Added

Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Ready to contribute? Here's how to set up `TekHSI` for local development.
1. Set up commit signing, see [GitHub's documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) for details.

!!! hint

All commits going into the main repository are required to be signed, so make sure
to set up commit signing before starting to make changes.

Expand Down Expand Up @@ -99,6 +100,7 @@ Ready to contribute? Here's how to set up `TekHSI` for local development.
formatting requirements and pass any tests.

!!! note

Always remember to activate the virtual environment before attempting to run tests or other code.

```console
Expand Down Expand Up @@ -135,6 +137,7 @@ Ready to contribute? Here's how to set up `TekHSI` for local development.
```

!!! note

Two html outputs are generated:

- Code coverage report: `.results_tests/htmlcov/index.html`
Expand All @@ -147,6 +150,7 @@ Ready to contribute? Here's how to set up `TekHSI` for local development.
```

!!! hint

To view the documentation locally you will need to first build and then serve the site using one of the following methods:

```console
Expand Down Expand Up @@ -181,6 +185,7 @@ To update the required python packages and commit hooks run the following
commands:

!!! note

Always remember to activate the virtual environment before attempting to run tests or other code.

```console
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{# TODO: Drop Python 3.8: remove this file after updating to newer versions of mkdocstrings-python #}
{% extends "_base/class.html.jinja" %}
{% block inheritance_diagram %}
{#- Inheritance diagram block.
Expand Down
1 change: 1 addition & 0 deletions docs/basic_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This example shows how to use `TekHSI` and `tm_data_types` to pull analog wavefo
Tektronix oscilloscope and save them to a csv file very easily.

!!! important

Matching the type of waveform with the channel type is critical. See the
[supported data types section](#supported-data-types) for more information.

Expand Down
10 changes: 7 additions & 3 deletions docs/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import pathlib
import re

from collections.abc import Generator
from importlib import import_module
from typing import Any, Generator, Optional, Set, Tuple
from typing import Any, Optional, Set, Tuple

import tomli

Expand Down Expand Up @@ -56,6 +57,9 @@
text = match.group(2).strip()
# Replace initial '>' from subsequent lines
text = text.replace("\n>", "\n")
# Check if the alert type "tip" should be converted to "hint"
if alert_type == "tip":
alert_type = "hint"
# Replace with admonition format
return f"!!! {alert_type}\n " + text.replace("\n", "\n ")

Expand Down Expand Up @@ -124,91 +128,91 @@
####################################################################################################
# Macro functions
####################################################################################################
def class_diagram( # noqa: C901 # pylint: disable=too-many-locals
*cls_or_modules: str,
full: bool = False,
strict: bool = False,
namespace: Optional[str] = None,
tree_direction: str = "up",
chart_direction: str = "LR",
highlight_family_base_classes: bool = False,
highlight_device_drivers: bool = False,
) -> str:
"""Create a mermaid classDiagram for the provided classes or modules.

Args:
cls_or_modules: A tuple of classes or modules.
full: A boolean indicating to show the complete class hierarchy.
strict: A boolean indicating to only consider classes that are strictly defined in that
module and not imported from somewhere else.
namespace: Limits the diagram to only include classes defined in this namespace.
tree_direction: A string indicating the direction of traversal in the class hierarchy,
either "up" or "down".
chart_direction: A string indicating the direction of the chart, either
"LR" (left to right), "RL" (right to left),
"TB" (top to bottom), or "BT" (bottom to top).
highlight_family_base_classes: Indicate to highlight the family base classes in cyan.
highlight_device_drivers: Indicate to highlight the device drivers in lightgreen.
highlight_device_drivers: Indicate to highlight the device drivers in lawngreen.

Returns:
The mermaid code block with complete syntax for the classDiagram.

Raises:
ValueError: If no classDiagram can be created.
"""
inheritances: Set[Tuple[str, str]] = set()
family_base_classes: Set[str] = set()
device_drivers: Set[str] = set()

def get_tree_upwards(cls: Any) -> None:
if getattr(cls, "_product_family_base_class", None) == cls:
family_base_classes.add(cls.__name__)
if abc.ABC not in cls.__bases__:
device_drivers.add(cls.__name__)

for base in cls.__bases__:
if base.__name__ == "object":
continue
if namespace and not base.__module__.startswith(namespace):
continue
inheritances.add((base.__name__, cls.__name__))
if full:
get_tree_upwards(base)

def get_tree_downwards(cls: Any) -> None:
if getattr(cls, "_product_family_base_class", None) == cls:
family_base_classes.add(cls.__name__)
if abc.ABC not in cls.__bases__:
device_drivers.add(cls.__name__)

for subclass in cls.__subclasses__():
if namespace and not subclass.__module__.startswith(namespace):
continue
inheritances.add((cls.__name__, subclass.__name__))
if full:
get_tree_downwards(subclass)

get_tree = get_tree_upwards if tree_direction == "up" else get_tree_downwards

for cls_item in get_classes(*cls_or_modules, strict=strict):
get_tree(cls_item)

if not inheritances:
msg = "No class hierarchy can be created."
raise ValueError(msg)

mermaid_code_block = f"```mermaid\nclassDiagram\n direction {chart_direction}\n" + "\n".join(
f" {a} <|-- {b}" for a, b in sorted(inheritances)
)
if highlight_family_base_classes:
for family_base_class in sorted(family_base_classes):
mermaid_code_block += f"\n style {family_base_class} stroke:orangered,stroke-width:4px"
if highlight_device_drivers:
for device_driver in sorted(device_drivers):
mermaid_code_block += f"\n style {device_driver} fill:lightgreen"
mermaid_code_block += f"\n style {device_driver} fill:lawngreen"
mermaid_code_block += "\n```"

return mermaid_code_block

Check notice on line 215 in docs/macros.py

View check run for this annotation

codefactor.io / CodeFactor

docs/macros.py#L131-L215

Complex Method


def create_repo_link(link_text: str, base_repo_url: str, relative_repo_path: str) -> str:
Expand Down
Loading
Loading