style: auto-format ranker and test_markdown_utils

This commit is contained in:
Kevin Turcios 2026-02-23 03:39:38 -05:00
parent 85a1c8b183
commit 16e043883a
2 changed files with 8 additions and 9 deletions

View file

@ -385,13 +385,9 @@ async def rank_optimizations( # noqa: D417
if json_response is not None:
logging.info("Successfully parsed JSON response")
ranking = (
_scores_to_ranking(json_response.scores)
if json_response.scores is not None
else json_response.ranking
)
return RankResponseSchema(
ranking=ranking, explanation=json_response.explanation, scores=json_response.scores
_scores_to_ranking(json_response.scores) if json_response.scores is not None else json_response.ranking
)
return RankResponseSchema(ranking=ranking, explanation=json_response.explanation, scores=json_response.scores)
# Fall back to regex parsing (legacy XML-tag format)
logging.info("JSON parsing failed, falling back to regex")

View file

@ -185,14 +185,17 @@ def test_extract_code_block_nested_code_fence_in_triple_quote() -> None:
# LLM embeds function definition in a triple-quoted string containing ```
text = '```python\nimport pytest\n_source = """```python:file.py\ndef foo(): pass\n```"""\ndef test_foo():\n assert True\n```'
result = extract_code_block(text)
assert result == 'import pytest\n_source = """```python:file.py\ndef foo(): pass\n```"""\ndef test_foo():\n assert True'
assert (
result
== 'import pytest\n_source = """```python:file.py\ndef foo(): pass\n```"""\ndef test_foo():\n assert True'
)
def test_extract_code_block_nested_code_fence_block() -> None:
# LLM nests a ```python:filepath block inside the main block
text = '```python\nimport pytest\n```python:src/mod.py\ndef foo(): pass\n```\ndef test_foo():\n assert True\n```'
text = "```python\nimport pytest\n```python:src/mod.py\ndef foo(): pass\n```\ndef test_foo():\n assert True\n```"
result = extract_code_block(text)
assert result == 'import pytest\n```python:src/mod.py\ndef foo(): pass\n```\ndef test_foo():\n assert True'
assert result == "import pytest\n```python:src/mod.py\ndef foo(): pass\n```\ndef test_foo():\n assert True"
def test_extract_all_code_single_block() -> None: