Skip to content
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
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,44 @@ concurrency:
cancel-in-progress: true

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:
Expand Down
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
66 changes: 66 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading