Skip to content

Commit f51bb17

Browse files
authored
Replace Black formatter with Ruff
2 parents f757b56 + f811fb4 commit f51bb17

7 files changed

Lines changed: 47 additions & 150 deletions

File tree

.github/workflows/tests.yml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,31 +99,19 @@ jobs:
9999
- name: mypy type check
100100
run: uv run mypy meilisearch
101101

102-
black:
103-
name: black
102+
ruff:
103+
name: ruff
104104
runs-on: ubuntu-latest
105-
env:
106-
PYTHONUNBUFFERED: 1
107-
UV_PYTHON: "3.9"
108-
UV_LOCKED: 1
109105
steps:
110106
- name: Checkout the repository
111107
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
112108
with:
113109
persist-credentials: false
114110

115-
- name: Set up Python 3.9
116-
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
111+
- name: ruff format
112+
uses: astral-sh/ruff-action@0ce1b0bf8b818ef400413f810f8a11cdbda0034b # v4.0.0
117113
with:
118-
python-version: 3.9
119-
120-
- name: Install uv
121-
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
122-
with:
123-
version: "0.11.21"
124-
125-
- name: black
126-
run: uv run black meilisearch tests --check
114+
args: "format --check"
127115

128116
isort:
129117
name: isort

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ uv sync
5656
### Tests and Linter <!-- omit in toc -->
5757

5858
Each PR should pass the tests, mypy type checking, and the linter to be accepted.
59-
Your PR also needs to be formatted using black and isort.
59+
Your PR also needs to be formatted using ruff and have its imports sorted using isort.
6060

6161
```bash
6262
# Tests
@@ -67,8 +67,8 @@ uv run pytest tests
6767
uv run mypy meilisearch
6868
# Linter
6969
uv run pylint meilisearch tests
70-
# Black
71-
uv run black meilisearch tests
70+
# Format
71+
uv run ruff format .
7272
# Isort
7373
uv run isort meilisearch tests
7474
```

meilisearch/_httprequests.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ def send_request(
7171
data = (
7272
json.dumps(body, cls=serializer)
7373
if isinstance(body, bool) or serialize_body
74-
else "" if body == "" else "null"
74+
else ""
75+
if body == ""
76+
else "null"
7577
)
7678

7779
request = http_method(
@@ -182,7 +184,9 @@ def post_stream(
182184
data = (
183185
json.dumps(body, cls=serializer)
184186
if isinstance(body, bool) or serialize_body
185-
else "" if body == "" else "null"
187+
else ""
188+
if body == ""
189+
else "null"
186190
)
187191

188192
response = requests.post(

pyproject.toml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test = [
4848
lint = [
4949
"mypy>=1.19.1",
5050
"pylint>=v3.3.9",
51-
"black>=25.11.0",
51+
"ruff>=0.15.17",
5252
"isort>=6.1.0",
5353
"types-requests",
5454
]
@@ -72,27 +72,8 @@ exclude = ["docs*", "tests*"]
7272
[tool.setuptools.package-data]
7373
meilisearch = ["py.typed"]
7474

75-
[tool.black]
75+
[tool.ruff]
7676
line-length = 100
77-
target-version = ['py39']
78-
include = '\.pyi?$'
79-
extend-exclude = '''
80-
/(
81-
\.egg
82-
| \.git
83-
| \.hg
84-
| \.mypy_cache
85-
| \.nox
86-
| \.tox
87-
| \.venv
88-
| \venv
89-
| _build
90-
| buck-out
91-
| build
92-
| dist
93-
| setup.py
94-
)/
95-
'''
9677

9778
[tool.isort]
9879
profile = "black"

tests/client/test_client_exports.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
)
1212

1313

14-
def test_export_creation(
15-
client, client2, index_with_documents, enable_vector_search
16-
): # pylint: disable=unused-argument
14+
def test_export_creation(client, client2, index_with_documents, enable_vector_search): # pylint: disable=unused-argument
1715
"""Tests the creation of a Meilisearch export."""
1816
index = index_with_documents()
1917
export_task = client.export(common.BASE_URL_2, api_key=common.MASTER_KEY)

tests/client/test_multimodal.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ def setup_index(self, request):
214214

215215
# Verify index is ready by checking stats
216216
stats = index.get_stats()
217-
assert stats.number_of_documents == len(
218-
MOVIES
219-
), f"Expected {len(MOVIES)} documents, got {stats.number_of_documents}"
217+
assert stats.number_of_documents == len(MOVIES), (
218+
f"Expected {len(MOVIES)} documents, got {stats.number_of_documents}"
219+
)
220220

221221
# Store for tests on the class
222222
# Use request.cls to ensure attributes are available on test instances

0 commit comments

Comments
 (0)