From 3a1ff528927d7ef26c2714e11a1404cd1be8db3a Mon Sep 17 00:00:00 2001 From: davidwilby <24752124+davidwilby@users.noreply.github.com> Date: Fri, 26 Apr 2024 14:10:14 +0100 Subject: [PATCH] use ruff linter with pre-commit hook and in github actions (#109) --- .github/workflows/style.yml | 6 +++--- .pre-commit-config.yaml | 9 +++++++++ pyproject.toml | 8 +++++++- requirements/requirements.dev.txt | 7 ++++--- 4 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 7e18ceeb..f9421532 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -16,10 +16,10 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - name: Install Black + - name: Install Ruff run: | python -m pip install --upgrade pip - pip install black + pip install ruff - name: Check style run: | - black --check *.py deepsensor tests \ No newline at end of file + ruff check \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..dad70628 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.4.2 + hooks: + # Run the linter. + - id: ruff + # Run the formatter. + - id: ruff-format \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 303a2511..baee1b41 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,4 +16,10 @@ warn_redundant_casts = true warn_return_any = true warn_unreachable = true warn_unused_configs = true -no_implicit_reexport = true \ No newline at end of file +no_implicit_reexport = true + +[tool.ruff.lint] +select = ["D"] + +[tool.ruff.lint.pydocstyle] +convention = "google" \ No newline at end of file diff --git a/requirements/requirements.dev.txt b/requirements/requirements.dev.txt index 6240a200..c2cd7f0e 100644 --- a/requirements/requirements.dev.txt +++ b/requirements/requirements.dev.txt @@ -1,8 +1,9 @@ # Additional requirements for development +coveralls +parameterized +pre-commit pytest pytest-cov -parameterized +ruff tox tox-gh-actions -coveralls -black