Skip to content

Commit 7d97288

Browse files
authored
Remove black (#2178)
1. Remove black 2. Applied `ruff format` to code which was inconsistent with ruff and black 3. Relevant edits in Makefile
1 parent 0374d24 commit 7d97288

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+117
-177
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ jobs:
179179
# Note: We use direct commands here instead of the standalone Makefiles
180180
# to have precise control over CI-specific options like --check for dry-run
181181
echo "Checking ragas formatting..."
182-
black --check --config ragas/pyproject.toml ragas/src ragas/tests docs
183-
ruff check ragas/src docs ragas/tests
182+
ruff format --check ragas/src ragas/tests docs --exclude ragas/src/ragas/_version.py
183+
ruff check ragas/src docs ragas/tests --exclude ragas/src/ragas/_version.py
184184
185185
- name: Type check
186186
run: make type

DEVELOPMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ cd ragas && uv run pytest tests/unit -k "test_name"
232232
### Code Quality Pipeline
233233
The `make format` command runs:
234234
1. **isort**: Import sorting
235-
2. **black**: Code formatting
235+
2. **ruff format**: Code formatting
236236
3. **ruff --fix-only**: Auto-fix issues (including unused imports)
237237
4. **ruff check**: Final linting validation
238238

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ run-ci: ## Run complete CI pipeline (mirrors GitHub CI exactly)
6969
run-ci-format-check: ## Run format check in dry-run mode (like GitHub CI)
7070
@echo "Running format check (dry-run, like GitHub CI)..."
7171
@echo "Checking ragas formatting..."
72-
$(Q)black --check --config ragas/pyproject.toml ragas/src ragas/tests docs
72+
$(Q)uv run ruff format --check ragas/src ragas/tests docs
7373
$(Q)ruff check ragas/src docs ragas/tests
7474

7575
run-ci-type: ## Run type checking (matches GitHub CI)
@@ -83,7 +83,7 @@ run-ci-tests: ## Run all tests with CI options
8383
run-ci-fast: ## Fast CI check for quick local validation (2-3 minutes)
8484
@echo "Running fast CI check for quick feedback..."
8585
@echo "Format check..."
86-
$(Q)black --check --config ragas/pyproject.toml ragas/src ragas/tests docs
86+
$(Q)uv run ruff format --check ragas/src ragas/tests docs
8787
$(Q)ruff check ragas/src docs ragas/tests
8888
@echo "Core unit tests (no nbmake for speed)..."
8989
$(Q)cd ragas && pytest tests/unit tests/experimental --dist loadfile -n auto -x

docs/howtos/customizations/testgenerator/testgen-custom-single-hop.ipynb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,9 @@
239239
"\n",
240240
"@dataclass\n",
241241
"class MySingleHopScenario(SingleHopQuerySynthesizer):\n",
242-
"\n",
243242
" theme_persona_matching_prompt = ThemesPersonasMatchingPrompt()\n",
244243
"\n",
245244
" async def _generate_scenarios(self, n, knowledge_graph, persona_list, callbacks):\n",
246-
"\n",
247245
" property_name = \"keyphrases\"\n",
248246
" nodes = []\n",
249247
" for node in knowledge_graph.nodes:\n",

docs/howtos/customizations/testgenerator/testgen-customisation.ipynb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@
258258
"\n",
259259
"@dataclass\n",
260260
"class MyMultiHopQuery(MultiHopQuerySynthesizer):\n",
261-
"\n",
262261
" theme_persona_matching_prompt = ThemesPersonasMatchingPrompt()\n",
263262
"\n",
264263
" async def _generate_scenarios(\n",
@@ -268,7 +267,6 @@
268267
" persona_list,\n",
269268
" callbacks,\n",
270269
" ) -> t.List[MultiHopScenario]:\n",
271-
"\n",
272270
" # query and get (node_a, rel, node_b) to create multi-hop queries\n",
273271
" results = kg.find_two_nodes_single_rel(\n",
274272
" relationship_condition=lambda rel: (\n",
@@ -284,7 +282,6 @@
284282
" node_a, node_b = triplet[0], triplet[-1]\n",
285283
" overlapped_keywords = triplet[1].properties[\"overlapped_items\"]\n",
286284
" if overlapped_keywords:\n",
287-
"\n",
288285
" # match the keyword with a persona for query creation\n",
289286
" themes = list(dict(overlapped_keywords).keys())\n",
290287
" prompt_input = ThemesPersonasInput(\n",

ragas/Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ help: ## Show all Makefile targets
1515

1616
format: ## Format and lint ragas code
1717
@echo "Formatting and linting ragas code..."
18-
@echo "(black) Formatting ragas..."
19-
$(Q)uv run black --config pyproject.toml $(RAGAS_PATHS)
20-
@echo "(black) Formatting stubs..."
21-
$(Q)find src -name "*.pyi" ! -name "*_pb2*" -exec uv run black --pyi --config pyproject.toml {} \;
18+
@echo "(ruff format) Formatting ragas..."
19+
$(Q)uv run ruff format $(RAGAS_PATHS)
2220
@echo "(ruff) Auto-fixing ragas (includes import sorting and unused imports)..."
2321
$(Q)uv run ruff check $(RAGAS_PATHS) --fix-only
2422
@echo "(ruff) Final linting check for ragas..."
@@ -39,7 +37,7 @@ test: ## Run ragas unit tests (including experimental)
3937
run-ci: ## Run complete CI pipeline for ragas
4038
@echo "Running ragas CI pipeline..."
4139
@echo "Format check..."
42-
$(Q)uv run black --check --config pyproject.toml $(RAGAS_PATHS)
40+
$(Q)uv run ruff format --check $(RAGAS_PATHS)
4341
$(Q)uv run ruff check $(RAGAS_PATHS)
4442
@echo "Type check..."
4543
$(Q)$(MAKE) type

ragas/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ markers = [
9696
[dependency-groups]
9797
dev = [
9898
"ruff",
99-
"black[jupyter]",
10099
"pyright>=1.1.403",
101100
"pre-commit>=4.3.0",
102101
"pytest",

ragas/src/ragas/callbacks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ def parse_run_traces(
135135
traces: t.Dict[str, ChainRun],
136136
parent_run_id: t.Optional[str] = None,
137137
) -> t.List[t.Dict[str, t.Any]]:
138-
139138
root_traces = [
140139
chain_trace
141140
for chain_trace in traces.values()

ragas/src/ragas/embeddings/base.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ def __get_pydantic_core_schema__(
9595
Define how Pydantic generates a schema for BaseRagasEmbeddings.
9696
"""
9797
return core_schema.no_info_after_validator_function(
98-
cls, core_schema.is_instance_schema(cls) # The validator function
98+
cls,
99+
core_schema.is_instance_schema(cls), # The validator function
99100
)
100101

101102

@@ -267,9 +268,9 @@ def embed_documents(self, texts: t.List[str]) -> t.List[t.List[float]]:
267268
from sentence_transformers.SentenceTransformer import SentenceTransformer
268269
from torch import Tensor
269270

270-
assert isinstance(
271-
self.model, SentenceTransformer
272-
), "Model is not of the type Bi-encoder"
271+
assert isinstance(self.model, SentenceTransformer), (
272+
"Model is not of the type Bi-encoder"
273+
)
273274
embeddings = self.model.encode(
274275
texts, normalize_embeddings=True, **self.encode_kwargs
275276
)
@@ -284,9 +285,9 @@ def predict(self, texts: t.List[t.List[str]]) -> t.List[t.List[float]]:
284285
from sentence_transformers.cross_encoder import CrossEncoder
285286
from torch import Tensor
286287

287-
assert isinstance(
288-
self.model, CrossEncoder
289-
), "Model is not of the type CrossEncoder"
288+
assert isinstance(self.model, CrossEncoder), (
289+
"Model is not of the type CrossEncoder"
290+
)
290291

291292
predictions = self.model.predict(texts, **self.encode_kwargs)
292293

ragas/src/ragas/embeddings/haystack_wrapper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ def __repr__(self) -> str:
117117
except ImportError:
118118
return f"{self.__class__.__name__}(embeddings=Unknown(...))"
119119

120-
if isinstance(self.embedder, (OpenAITextEmbedder, SentenceTransformersTextEmbedder)): # type: ignore
120+
if isinstance(
121+
self.embedder, (OpenAITextEmbedder, SentenceTransformersTextEmbedder)
122+
): # type: ignore
121123
model_info = self.embedder.model
122124
elif isinstance(self.embedder, AzureOpenAITextEmbedder): # type: ignore
123125
model_info = self.embedder.azure_deployment

0 commit comments

Comments
 (0)