chore: simplify Haystack Hatch scripts (#9491)

* try unifying hatch scripts

* formatting

* simplify

* improve contributing guidelines

* fmt-check
This commit is contained in:
Stefano Fiorucci 2025-06-06 10:43:02 +02:00 committed by GitHub
parent b61886b138
commit 12665ade14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 18 additions and 60 deletions

View File

@ -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

View File

@ -45,11 +45,8 @@ jobs:
- name: Install Hatch - name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }} run: pip install hatch==${{ env.HATCH_VERSION }}
- name: Check file format - name: Ruff - check format and linting
run: hatch run format-check run: hatch run fmt-check
- name: Check linting
run: hatch run check
- name: Check presence of license header - name: Check presence of license header
run: docker run --rm -v "$(pwd):/github/workspace" ghcr.io/korandoru/hawkeye check run: docker run --rm -v "$(pwd):/github/workspace" ghcr.io/korandoru/hawkeye check

View File

@ -17,10 +17,11 @@ repos:
args: [--markdown-linebreak-ext=md] args: [--markdown-linebreak-ext=md]
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.0 rev: v0.11.12
hooks: hooks:
- id: ruff - id: ruff-check
- id: ruff-format args: [ --fix ]
- id: ruff-format
- repo: https://github.com/codespell-project/codespell - repo: https://github.com/codespell-project/codespell
rev: v2.3.0 rev: v2.3.0

View File

@ -160,7 +160,7 @@ and keep reading once you can run from your terminal:
```console ```console
$ hatch --version $ 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: 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. 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 ```sh
hatch run test:types hatch run test:types
``` ```
To format your code and perform linting using Ruff (with automatic fixes), run:
To check your code format run:
```sh ```sh
hatch run format-check hatch run fmt
``` ```
To format your code, you can run: To run linting with Pylint, use:
```sh
hatch run format
````
To check your code style according to linting rules run:
```sh ```sh
hatch run check
hatch run test:lint 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 ## Requirements for Pull Requests
To ease the review process, please follow the instructions in this paragraph when creating a Pull Request: To ease the review process, please follow the instructions in this paragraph when creating a Pull Request:

View File

@ -36,7 +36,7 @@ class AzureOpenAITextEmbedder(OpenAITextEmbedder):
""" """
# pylint: disable=super-init-not-called # 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, self,
azure_endpoint: Optional[str] = None, azure_endpoint: Optional[str] = None,
api_version: Optional[str] = "2023-05-15", api_version: Optional[str] = "2023-05-15",

View File

@ -55,7 +55,7 @@ class AzureOpenAIGenerator(OpenAIGenerator):
""" """
# pylint: disable=super-init-not-called # 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, self,
azure_endpoint: Optional[str] = None, azure_endpoint: Optional[str] = None,
api_version: Optional[str] = "2023-05-15", api_version: Optional[str] = "2023-05-15",

View File

@ -76,10 +76,8 @@ dependencies = [
[tool.hatch.envs.default.scripts] [tool.hatch.envs.default.scripts]
release-note = "reno new {args}" release-note = "reno new {args}"
check = "ruff check {args}" fmt = "ruff check --fix {args} && ruff format {args}"
fix = "ruff check --fix" fmt-check = "ruff check {args} && ruff format --check {args}"
format = "ruff format {args}"
format-check = "ruff format --check {args}"
[tool.hatch.envs.test] [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 = 'pytest --maxfail=5 -m "integration" {args:test}'
integration-only-fast = 'pytest --maxfail=5 -m "integration and not slow" {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}' 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}" types = "mypy --install-types --non-interactive --cache-dir=.mypy_cache/ {args:haystack}"
lint = "pylint -ry -j 0 {args:haystack}" lint = "pylint -ry -j 0 {args:haystack}"