Skip to content

Commit 12665ad

Browse files
authored
chore: simplify Haystack Hatch scripts (#9491)
* try unifying hatch scripts * formatting * simplify * improve contributing guidelines * fmt-check
1 parent b61886b commit 12665ad

7 files changed

Lines changed: 17 additions & 59 deletions

File tree

.github/workflows/docstrings_linting.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,8 @@ jobs:
4545
- name: Install Hatch
4646
run: pip install hatch==${{ env.HATCH_VERSION }}
4747

48-
- name: Check file format
49-
run: hatch run format-check
50-
51-
- name: Check linting
52-
run: hatch run check
48+
- name: Ruff - check format and linting
49+
run: hatch run fmt-check
5350

5451
- name: Check presence of license header
5552
run: docker run --rm -v "$(pwd):/github/workspace" ghcr.io/korandoru/hawkeye check

.pre-commit-config.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ repos:
1717
args: [--markdown-linebreak-ext=md]
1818

1919
- repo: https://github.com/astral-sh/ruff-pre-commit
20-
rev: v0.11.0
20+
rev: v0.11.12
2121
hooks:
22-
- id: ruff
23-
- id: ruff-format
22+
- id: ruff-check
23+
args: [ --fix ]
24+
- id: ruff-format
2425

2526
- repo: https://github.com/codespell-project/codespell
2627
rev: v2.3.0

CONTRIBUTING.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ and keep reading once you can run from your terminal:
160160

161161
```console
162162
$ hatch --version
163-
Hatch, version 1.9.3
163+
Hatch, version 1.14.1
164164
```
165165

166166
You can create a new virtual environment for Haystack with `hatch` by running:
@@ -239,35 +239,24 @@ We also use tools to ensure consistent code style, quality, and static type chec
239239
tested by the CI, but once again, running the checks locally will speed up the review cycle.
240240

241241

242-
To check your code type checking, run:
242+
To check for static type errors, run:
243243
```sh
244244
hatch run test:types
245245
```
246246

247-
248-
To check your code format run:
247+
To format your code and perform linting using Ruff (with automatic fixes), run:
249248
```sh
250-
hatch run format-check
249+
hatch run fmt
251250
```
252251

253252

254-
To format your code, you can run:
255-
```sh
256-
hatch run format
257-
````
258-
253+
To run linting with Pylint, use:
259254

260-
To check your code style according to linting rules run:
261255
```sh
262-
hatch run check
263256
hatch run test:lint
264-
````
257+
```
265258

266259

267-
If the linters spot any error, you can fix it before checking in your code:
268-
```sh
269-
hatch run fix
270-
```
271260

272261

273262
## Requirements for Pull Requests

haystack/components/embedders/azure_text_embedder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class AzureOpenAITextEmbedder(OpenAITextEmbedder):
3636
"""
3737

3838
# pylint: disable=super-init-not-called
39-
def __init__( # pylint: disable=too-many-positional-arguments
39+
def __init__( # pylint: disable=too-many-positional-arguments # noqa: PLR0913
4040
self,
4141
azure_endpoint: Optional[str] = None,
4242
api_version: Optional[str] = "2023-05-15",

haystack/components/generators/azure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class AzureOpenAIGenerator(OpenAIGenerator):
5555
"""
5656

5757
# pylint: disable=super-init-not-called
58-
def __init__( # pylint: disable=too-many-positional-arguments
58+
def __init__( # pylint: disable=too-many-positional-arguments # noqa: PLR0913
5959
self,
6060
azure_endpoint: Optional[str] = None,
6161
api_version: Optional[str] = "2023-05-15",

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ dependencies = [
7676

7777
[tool.hatch.envs.default.scripts]
7878
release-note = "reno new {args}"
79-
check = "ruff check {args}"
80-
fix = "ruff check --fix"
81-
format = "ruff format {args}"
82-
format-check = "ruff format --check {args}"
79+
fmt = "ruff check --fix {args} && ruff format {args}"
80+
fmt-check = "ruff check {args} && ruff format --check {args}"
8381

8482
[tool.hatch.envs.test]
8583

@@ -153,6 +151,7 @@ unit = 'pytest --cov-report xml:coverage.xml --cov="haystack" -m "not integratio
153151
integration = 'pytest --maxfail=5 -m "integration" {args:test}'
154152
integration-only-fast = 'pytest --maxfail=5 -m "integration and not slow" {args:test}'
155153
integration-only-slow = 'pytest --maxfail=5 -m "integration and slow" {args:test}'
154+
all = 'pytest {args:test}'
156155

157156
types = "mypy --install-types --non-interactive --cache-dir=.mypy_cache/ {args:haystack}"
158157
lint = "pylint -ry -j 0 {args:haystack}"

0 commit comments

Comments
 (0)