diff --git a/.github/workflows/docstrings_linting.yml b/.github/workflows/docstrings_linting.yml deleted file mode 100644 index 724a5028d..000000000 --- a/.github/workflows/docstrings_linting.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: run docstrings linting - -on: - pull_request: - types: - - opened - - reopened - - synchronize - - ready_for_review - paths: - - "**.py" - -env: - HATCH_VERSION: "1.14.1" - -jobs: - docstrings-linting: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Hatch - run: pip install hatch==${{ env.HATCH_VERSION }} - - - name: ruff docstrings linting - run: hatch run ruff check haystack diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fde297ca3..46c02b5b5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,11 +45,8 @@ jobs: - name: Install Hatch run: pip install hatch==${{ env.HATCH_VERSION }} - - name: Check file format - run: hatch run format-check - - - name: Check linting - run: hatch run check + - name: Ruff - check format and linting + run: hatch run fmt-check - name: Check presence of license header run: docker run --rm -v "$(pwd):/github/workspace" ghcr.io/korandoru/hawkeye check diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dccc64adb..a4a9a7267 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,10 +17,11 @@ repos: args: [--markdown-linebreak-ext=md] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.0 + rev: v0.11.12 hooks: - - id: ruff - - id: ruff-format + - id: ruff-check + args: [ --fix ] + - id: ruff-format - repo: https://github.com/codespell-project/codespell rev: v2.3.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1f14e1dd8..c36f05d16 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -160,7 +160,7 @@ and keep reading once you can run from your terminal: ```console $ hatch --version -Hatch, version 1.9.3 +Hatch, version 1.14.1 ``` You can create a new virtual environment for Haystack with `hatch` by running: @@ -239,37 +239,26 @@ We also use tools to ensure consistent code style, quality, and static type chec tested by the CI, but once again, running the checks locally will speed up the review cycle. -To check your code type checking, run: +To check for static type errors, run: ```sh hatch run test:types ``` - -To check your code format run: +To format your code and perform linting using Ruff (with automatic fixes), run: ```sh -hatch run format-check +hatch run fmt ``` -To format your code, you can run: -```sh -hatch run format -```` +To run linting with Pylint, use: - -To check your code style according to linting rules run: ```sh -hatch run check hatch run test:lint -```` - - -If the linters spot any error, you can fix it before checking in your code: -```sh -hatch run fix ``` + + ## Requirements for Pull Requests To ease the review process, please follow the instructions in this paragraph when creating a Pull Request: diff --git a/haystack/components/embedders/azure_text_embedder.py b/haystack/components/embedders/azure_text_embedder.py index 85104142c..f3f59be92 100644 --- a/haystack/components/embedders/azure_text_embedder.py +++ b/haystack/components/embedders/azure_text_embedder.py @@ -36,7 +36,7 @@ class AzureOpenAITextEmbedder(OpenAITextEmbedder): """ # pylint: disable=super-init-not-called - def __init__( # pylint: disable=too-many-positional-arguments + def __init__( # pylint: disable=too-many-positional-arguments # noqa: PLR0913 self, azure_endpoint: Optional[str] = None, api_version: Optional[str] = "2023-05-15", diff --git a/haystack/components/generators/azure.py b/haystack/components/generators/azure.py index 358bab256..01e4444b3 100644 --- a/haystack/components/generators/azure.py +++ b/haystack/components/generators/azure.py @@ -55,7 +55,7 @@ class AzureOpenAIGenerator(OpenAIGenerator): """ # pylint: disable=super-init-not-called - def __init__( # pylint: disable=too-many-positional-arguments + def __init__( # pylint: disable=too-many-positional-arguments # noqa: PLR0913 self, azure_endpoint: Optional[str] = None, api_version: Optional[str] = "2023-05-15", diff --git a/pyproject.toml b/pyproject.toml index 73cd0d2ca..1447e73bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,10 +76,8 @@ dependencies = [ [tool.hatch.envs.default.scripts] release-note = "reno new {args}" -check = "ruff check {args}" -fix = "ruff check --fix" -format = "ruff format {args}" -format-check = "ruff format --check {args}" +fmt = "ruff check --fix {args} && ruff format {args}" +fmt-check = "ruff check {args} && ruff format --check {args}" [tool.hatch.envs.test] @@ -153,6 +151,7 @@ unit = 'pytest --cov-report xml:coverage.xml --cov="haystack" -m "not integratio integration = 'pytest --maxfail=5 -m "integration" {args:test}' integration-only-fast = 'pytest --maxfail=5 -m "integration and not slow" {args:test}' integration-only-slow = 'pytest --maxfail=5 -m "integration and slow" {args:test}' +all = 'pytest {args:test}' types = "mypy --install-types --non-interactive --cache-dir=.mypy_cache/ {args:haystack}" lint = "pylint -ry -j 0 {args:haystack}"