Skip to content

Commit 6126bd9

Browse files
authored
fix: docstrings (#177)
* fix: reformat docstrings * fix: remove extra params from docstring * fix: remove cli and docs from linter
1 parent 8fece40 commit 6126bd9

File tree

38 files changed

+228
-88
lines changed

38 files changed

+228
-88
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
- id: ruff
1212
name: "Ruff linter"
1313
args: [--exit-non-zero-on-fix, --fix, --config=pyproject.toml]
14-
files: '^(mellea|tests|cli|docs).*\.(py|ipynb)$'
14+
files: '^(mellea|tests).*\.(py|ipynb)$'
1515

1616
- repo: local
1717
hooks:

cli/alora/upload.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66

77
def upload_model(weight_path: str, model_name: str, private: bool = True):
8-
"""
9-
Upload a trained adapter (LoRA/aLoRA) to Hugging Face Hub.
8+
"""Upload a trained adapter (LoRA/aLoRA) to Hugging Face Hub.
109
1110
Args:
1211
weight_path (str): Directory containing adapter weights (from save_pretrained).

cli/m.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# Add a default callback for handling the default cli description.
1313
@cli.callback()
1414
def callback() -> None:
15-
"""Perform M Tasks"""
15+
"""Perform M Tasks."""
1616

1717

1818
# Typer assumes that all commands are in the same file/module.

docs/examples/best_of_n/prm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Example of Using Best of N with PRMs"""
1+
"""Example of Using Best of N with PRMs."""
22

33
from docs.examples.helper import w
44
from mellea import start_session

docs/examples/generative_slots/generative_slots.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ def classify_sentiment(text: str) -> Literal["positive", "negative"]: ...
99

1010
@generative
1111
def generate_summary(text: str) -> str:
12-
"""
13-
This is a function that takes in a string and generates a summary for the string.
12+
"""This is a function that takes in a string and generates a summary for the string.
1413
Keep your summary succinct and under 20 words.
1514
"""
1615

docs/examples/information_extraction/101_with_gen_slots.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
@generative
1010
def extract_all_person_names(doc: str) -> list[str]:
11-
"""
12-
Given a document, extract all person names. Return these names as list of strings.
13-
"""
11+
"""Given a document, extract all person names. Return these names as list of strings."""
1412

1513

1614
# ref: https://www.nytimes.com/2012/05/20/world/world-leaders-at-us-meeting-urge-growth-not-austerity.html

docs/examples/mini_researcher/researcher.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@
1919

2020
@cache
2121
def get_session():
22-
"""get M session (change model here)"""
22+
"""Get M session (change model here)."""
2323
return MelleaSession(backend=OllamaModelBackend(model_ids.IBM_GRANITE_3_3_8B))
2424

2525

2626
@cache
2727
def get_guardian_session():
28-
"""get M session for the guardian model"""
28+
"""Get M session for the guardian model."""
2929
return MelleaSession(
3030
backend=OllamaModelBackend(model_ids.IBM_GRANITE_GUARDIAN_3_0_2B)
3131
)
3232

3333

3434
def is_a_true_subset_of_b(a: list[str], b: list[str]) -> bool:
35-
"""check if a is true subset of b."""
35+
"""Check if a is true subset of b."""
3636
all_in = True
3737
for e in a:
3838
if e not in b:
@@ -42,7 +42,7 @@ def is_a_true_subset_of_b(a: list[str], b: list[str]) -> bool:
4242

4343

4444
def create_check_word_count(max_words: int) -> Callable[[str], bool]:
45-
"""generate a maximum-word-count validation function."""
45+
"""Generate a maximum-word-count validation function."""
4646

4747
def cc(s: str):
4848
return len(s.split()) <= max_words
@@ -56,7 +56,7 @@ def cc(s: str):
5656

5757

5858
def step_is_input_safe(guardian_session: MelleaSession, docs: list[str]) -> bool:
59-
"""check if the list of docs has no harm."""
59+
"""Check if the list of docs has no harm."""
6060
is_safe = True
6161
for i_doc, doc in enumerate(docs):
6262
print(f"\nChecking Doc {i_doc + 1}/{len(docs)}", end="...")
@@ -73,7 +73,7 @@ def step_is_input_safe(guardian_session: MelleaSession, docs: list[str]) -> bool
7373
def step_summarize_docs(
7474
s: MelleaSession, docs: list[str], user_args: dict
7575
) -> list[str]:
76-
"""generate a task-specific document summary for each doc."""
76+
"""Generate a task-specific document summary for each doc."""
7777
summaries = []
7878
for i_doc, doc in enumerate(docs): # type: ignore
7979
print(f"\nSummarizing doc {i_doc + 1}/{len(docs)}", end="...")
@@ -91,7 +91,6 @@ def step_generate_outline(
9191
s: MelleaSession, user_args: dict, context: list[RAGDocument]
9292
) -> list[str]:
9393
"""Generate a report outline using constraint decoding (formatted output)."""
94-
9594
print("\n Generating outline", end="...")
9695

9796
class SectionTitles(BaseModel):
@@ -165,7 +164,6 @@ def step_write_full_report(
165164
outline: list[str],
166165
) -> str:
167166
"""Merge summaries and outline into a single report."""
168-
169167
print("\nWriting full report", end="...")
170168

171169
## Define Requirements

docs/examples/notebooks/mcp_example.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
"\n",
127127
"@mcp.resource(\"greeting://{name}\")\n",
128128
"def get_greeting(name: str) -> str:\n",
129-
" \"\"\"Get a personalized greeting\"\"\"\n",
129+
" \"\"\"Get a personalized greeting.\"\"\"\n",
130130
" return f\"Hello, {name}!\""
131131
]
132132
}

docs/examples/safety.py/guardian.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Example of using the Guardian Requirement"""
1+
"""Example of using the Guardian Requirement."""
22

33
from mellea import MelleaSession
44
from mellea.backends import model_ids

docs/examples/tutorial/mcp_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Example of an MCP server
1+
"""Example of an MCP server.
22
33
You need to install the mcp package:
44
uv pip install "mcp[cli]"
@@ -50,5 +50,5 @@ def write_a_poem(word_limit: int) -> str:
5050

5151
@mcp.resource("greeting://{name}")
5252
def get_greeting(name: str) -> str:
53-
"""Get a personalized greeting"""
53+
"""Get a personalized greeting."""
5454
return f"Hello, {name}!"

0 commit comments

Comments
 (0)