diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000..fd8543b --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,16 @@ +name: Ruff +on: + push: + branches: + - main + - dev + pull_request: +jobs: + ruff: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/ruff-action@v3 + with: + args: check --output-format=github \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..d44a7fa --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: + +# pre-commit-hooks +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: check-merge-conflict + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace +# ruff +repos: +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.11.7 + hooks: + # Run the linter. + - id: ruff \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 3cb7052..12ae8ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,6 +66,12 @@ docs = [ "numpydoc>=1.5.0", "myst-nb>=0.17.1", ] +dev = [ + {include-group = "docs"}, + {include-group = "testing"}, + "pre-commit", + "ruff<=0.11.4", +] [project.optional-dependencies] jupyter = [ @@ -77,6 +83,29 @@ jupyter = [ "jupyterlab", ] +[tool.ruff] +src = ["cadetrdm", "tests"] +exclude = ["examples", "docs"] +line-length = 88 + +[tool.ruff.lint] +preview = true +select = ["E", "F", "W", "D", "ANN"] +ignore = ["D100", "D212", "D203", "ANN401"] +exclude = ['__init__.py'] + +[tool.ruff.lint.pydocstyle] +convention = "numpy" + +[tool.ruff.lint.pycodestyle] +max-line-length = 100 +max-doc-length = 94 + +[tool.ruff.lint.per-file-ignores] +"tests/*.py" = ["D", "E731", "ANN", "E402"] +# E731 are lambda expressions for tests, D are general docstrings + + [tool.pytest.ini_options] markers = [ "slow: marks tests as slow (deselect with '-m \"not slow\"')",