Skip to content

Commit 022ae2c

Browse files
Fix formatting
1 parent 4fc57af commit 022ae2c

2 files changed

Lines changed: 13 additions & 22 deletions

File tree

  • osa_tool/operations/codebase/docstring_generation
  • tests/unit/operations/codebase/docstring_generation

osa_tool/operations/codebase/docstring_generation/docgen.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,7 @@ def _get_method_generation_prompt_small(self, method_details: dict, context_code
524524
if context_code
525525
else ""
526526
),
527-
constructor_rules=(
528-
self._render_prompt("method_generation_small_constructor") if is_constructor else ""
529-
),
527+
constructor_rules=(self._render_prompt("method_generation_small_constructor") if is_constructor else ""),
530528
)
531529

532530
async def update_method_documentation(
@@ -543,9 +541,7 @@ async def update_method_documentation(
543541
docstring = method_details["docstring"]
544542

545543
if language in ("javascript", "typescript"):
546-
prompt = self._get_method_update_prompt_large(
547-
method_details, docstring, context_code, class_name, language
548-
)
544+
prompt = self._get_method_update_prompt_large(method_details, docstring, context_code, class_name, language)
549545
elif self.is_small_model:
550546
prompt = self._get_method_update_prompt_small(method_details, docstring, context_code, class_name)
551547
else:
@@ -606,11 +602,7 @@ def _get_method_update_prompt_large(
606602
class_location=f" (located inside {class_name} class)" if class_name else "",
607603
decorators=method_details["decorators"],
608604
source_code=method_details["source_code"],
609-
context=(
610-
self._render_prompt("method_update_standard_context", context_code=context_code)
611-
if context_code
612-
else ""
613-
),
605+
context=(self._render_prompt("method_update_standard_context", context_code=context_code) if context_code else ""),
614606
main_idea=self.main_idea,
615607
)
616608

@@ -629,11 +621,7 @@ def _get_method_update_prompt_small(
629621
constructor_rules=self._render_prompt(
630622
"method_update_small_constructor" if is_constructor else "method_update_small_non_constructor"
631623
),
632-
context=(
633-
self._render_prompt("method_update_small_context", context_code=context_code)
634-
if context_code
635-
else ""
636-
),
624+
context=(self._render_prompt("method_update_small_context", context_code=context_code) if context_code else ""),
637625
main_idea=self.main_idea,
638626
)
639627

@@ -709,8 +697,10 @@ def clean_docstring(docstring: str) -> str:
709697
while next_index < len(lines) and not lines[next_index].strip():
710698
next_index += 1
711699
next_line = lines[next_index].strip().lower() if next_index < len(lines) else ""
712-
if not next_line or next_line == "none" or re.match(
713-
r"^(Args|Returns|Raises|Attributes):", next_line, re.IGNORECASE
700+
if (
701+
not next_line
702+
or next_line == "none"
703+
or re.match(r"^(Args|Returns|Raises|Attributes):", next_line, re.IGNORECASE)
714704
):
715705
index = next_index + (next_line == "none")
716706
continue
@@ -1458,12 +1448,14 @@ async def generate_the_main_idea(self, parsed_structure: dict, top_n: int = 5) -
14581448
else:
14591449
docstring = component["details"]["docstring"] if component["details"]["docstring"] else ""
14601450

1461-
prompt_structure.append(f"""
1451+
prompt_structure.append(
1452+
f"""
14621453
{_type.capitalize()} name: {component["name"] if _type == "class" else component["details"]["method_name"]}
14631454
Component description: {docstring}
14641455
Component place in hierarchy: {file}
14651456
Component importance score: {score}
1466-
""")
1457+
"""
1458+
)
14671459

14681460
logger.info(f"Generating the main idea of the project...")
14691461

@@ -1492,7 +1484,6 @@ async def summarize_submodules(self, project_structure: dict[str, Any], rate_lim
14921484

14931485
semaphore = asyncio.Semaphore(rate_limit)
14941486

1495-
14961487
_summaries = {}
14971488

14981489
async def summarize_directory(name: str, file_summaries: List[str], submodule_summaries: List[str]) -> str:

tests/unit/operations/codebase/docstring_generation/test_docgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ def test_extract_pure_docstring_preserves_escaped_triple_quotes_in_content(mock_
563563

564564
result = docgen.extract_pure_docstring('"""Return \\"\\"\\" as the delimiter."""')
565565

566-
assert r'\"\"\"' in result
566+
assert r"\"\"\"" in result
567567
assert "as the delimiter." in result
568568

569569

0 commit comments

Comments
 (0)