From 101280d637ccea8e334a08fd91f364938ebf3a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20Kir=C3=A1ly?= Date: Wed, 13 Aug 2025 23:46:34 +0200 Subject: [PATCH 1/4] Update pyproject.toml --- pyproject.toml | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c7c62a0a..e9d58347 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,3 +69,69 @@ all_extras = [ "Homepage" = "https://github.com/SimonBlanke/Hyperactive" "Bug Reports" = "https://github.com/SimonBlanke/Hyperactive/issues" "Source" = "https://github.com/SimonBlanke/Hyperactive/" + + +[tool.ruff] +line-length = 88 +exclude = [".git", "examples/*"] +target-version = "py39" +extend-include = ["*.ipynb"] + +[tool.ruff.lint] +select = [ + # https://pypi.org/project/pycodestyle + "D", + "E", + "W", + # https://pypi.org/project/pyflakes + "F", + # https://pypi.org/project/flake8-bandit + "S", + # https://docs.astral.sh/ruff/rules/#pyupgrade-up + "UP", + "I002", # Missing required imports + "UP008", # Super calls with redundant arguments passed. + "G010", # Deprecated log warn. + "PLR1722", # Use sys.exit() instead of exit() and quit(). + "PT014", # pytest-duplicate-parametrize-test-cases. + "PT006", # Checks for the type of parameter names passed to pytest.mark.parametrize. + "PT007", # Checks for the type of parameter values passed to pytest.mark.parametrize. + "PT018", # Checks for assertions that combine multiple independent condition + "RUF001", # Checks for non unicode string literals + "RUF002", # Checks for non unicode string literals + "RUF003", # Checks for non unicode string literals +] +extend-select = [ + "I", # isort + "C4", # https://pypi.org/project/flake8-comprehensions +] +ignore=[ + "E203", # Whitespace-before-punctuation. + "E402", # Module-import-not-at-top-of-file. + "E731", # Do not assign a lambda expression, use a def. + "RET504", # Unnecessary variable assignment before `return` statement. + "S101", # Use of `assert` detected. + "RUF100", # https://docs.astral.sh/ruff/rules/unused-noqa/ + "C408", # Unnecessary dict call - rewrite as a literal. + "UP031", # Use format specifier instead of % + "S102", # Use of excec + "C414", # Unnecessary `list` call within `sorted()` + "S301", # pickle and modules that wrap it can be unsafe + "C416", # Unnecessary list comprehension - rewrite as a generator + "S310", # Audit URL open for permitted schemes + "S202", # Uses of `tarfile.extractall()` + "S307", # Use of possibly insecure function + "C417", # Unnecessary `map` usage (rewrite using a generator expression) + "S605", # Starting a process with a shell, possible injection detected + "E741", # Ambiguous variable name + "S107", # Possible hardcoded password + "S105", # Possible hardcoded password + "PT018", # Checks for assertions that combine multiple independent condition + "S602", # sub process call with shell=True unsafe + "C419", # Unnecessary list comprehension, some are flagged yet are not + "C409", # Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) + "S113", # Probable use of httpx call without timeout +] + +[tool.ruff.lint.pydocstyle] +convention = "numpy" From 715be91f7fdad57c3cd3d8e33ce55ce1adbde6fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20Kir=C3=A1ly?= Date: Wed, 13 Aug 2025 23:50:51 +0200 Subject: [PATCH 2/4] test --- .github/workflows/test.yml | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0088c96f..0083995f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,45 @@ concurrency: cancel-in-progress: true jobs: +jobs: + code-quality: + name: code-quality + runs-on: ubuntu-latest + steps: + - name: repository checkout step + uses: actions/checkout@v5 + + - name: python environment step + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: install pre-commit + run: python3 -m pip install pre-commit + + - name: Checkout code + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Get changed files + id: changed-files + run: | + CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr '\n' ' ') + echo "CHANGED_FILES=${CHANGED_FILES}" >> $GITHUB_ENV + + - name: Print changed files + run: | + echo "Changed files:" && echo "$CHANGED_FILES" | tr ' ' '\n' + + - name: Run pre-commit on changed files + run: | + if [ -n "$CHANGED_FILES" ]; then + pre-commit run --color always --files $CHANGED_FILES --show-diff-on-failure + else + echo "No changed files to check." + fi + test-no-extras: name: test-no-extras strategy: From f8129672ad9cd4a5b0f52dc4babb30924a8a6a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20Kir=C3=A1ly?= Date: Wed, 13 Aug 2025 23:51:01 +0200 Subject: [PATCH 3/4] Update test.yml --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0083995f..1986ba8a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -jobs: jobs: code-quality: name: code-quality From 12651728b30dafabf22a6343f840aa5267d903ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20Kir=C3=A1ly?= Date: Wed, 13 Aug 2025 23:53:16 +0200 Subject: [PATCH 4/4] Create .pre-commit-config.yaml --- .pre-commit-config.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..4089d714 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-ast + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.9 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format + + - repo: https://github.com/nbQA-dev/nbQA + rev: 1.8.7 + hooks: + - id: nbqa-black + - id: nbqa-ruff + - id: nbqa-check-ast