Skip to content

Commit 1602bb8

Browse files
committed
ruff format
1 parent 68bef39 commit 1602bb8

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/doc_builder/convert_md_to_mdx.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,18 +312,14 @@ def _clean_code_for_doc(code):
312312

313313
if skipping:
314314
# Track parentheses / brackets to find end of multi-line statement
315-
paren_depth += (
316-
stripped.count("(") - stripped.count(")") + stripped.count("[") - stripped.count("]")
317-
)
315+
paren_depth += stripped.count("(") - stripped.count(")") + stripped.count("[") - stripped.count("]")
318316
if paren_depth <= 0 and not stripped.rstrip().endswith("\\"):
319317
skipping = False
320318
continue
321319

322320
if _should_hide_line(stripped):
323321
if _is_multiline(stripped):
324-
paren_depth = (
325-
stripped.count("(") - stripped.count(")") + stripped.count("[") - stripped.count("]")
326-
)
322+
paren_depth = stripped.count("(") - stripped.count(")") + stripped.count("[") - stripped.count("]")
327323
skipping = True
328324
elif _re_block_opener.match(stripped):
329325
# Block opener with # nodoc — skip the entire indented body

tests/test_convert_md_to_mdx.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def test_clean_runnable_blocks_nodoc_collapses_blank_lines(self):
479479

480480
def test_clean_runnable_blocks_glmasr_batched(self):
481481
"""Real-world test from huggingface/transformers PR #44277 — test_batched block with # nodoc."""
482-
text = '''```py runnable:test_batched
482+
text = """```py runnable:test_batched
483483
import torch
484484
from transformers import AutoProcessor, GlmAsrForConditionalGeneration
485485
@@ -540,8 +540,8 @@ def test_clean_runnable_blocks_glmasr_batched(self):
540540
"This week, I traveled to Chicago to deliver my final farewell address to the nation.",
541541
]
542542
assert decoded_outputs == EXPECTED_OUTPUT # nodoc
543-
```'''
544-
expected = '''```py
543+
```"""
544+
expected = """```py
545545
import torch
546546
from transformers import AutoProcessor, GlmAsrForConditionalGeneration
547547
@@ -586,12 +586,12 @@ def test_clean_runnable_blocks_glmasr_batched(self):
586586
decoded_outputs = processor.batch_decode(
587587
outputs[:, inputs.input_ids.shape[1] :], skip_special_tokens=True
588588
)
589-
```'''
589+
```"""
590590
self.assertEqual(clean_runnable_blocks(text), expected)
591591

592592
def test_clean_runnable_blocks_glmasr_basic(self):
593593
"""Real-world test from huggingface/transformers PR #44277 — test_basic block (no asserts)."""
594-
text = '''```py runnable:test_basic
594+
text = """```py runnable:test_basic
595595
from transformers import AutoModelForSeq2SeqLM, AutoProcessor
596596
597597
processor = AutoProcessor.from_pretrained("zai-org/GLM-ASR-Nano-2512")
@@ -606,8 +606,8 @@ def test_clean_runnable_blocks_glmasr_basic(self):
606606
607607
decoded_outputs = processor.batch_decode(outputs[:, inputs.input_ids.shape[1] :], skip_special_tokens=True)
608608
print(decoded_outputs)
609-
```'''
610-
expected = '''```py
609+
```"""
610+
expected = """```py
611611
from transformers import AutoModelForSeq2SeqLM, AutoProcessor
612612
613613
processor = AutoProcessor.from_pretrained("zai-org/GLM-ASR-Nano-2512")
@@ -622,5 +622,5 @@ def test_clean_runnable_blocks_glmasr_basic(self):
622622
623623
decoded_outputs = processor.batch_decode(outputs[:, inputs.input_ids.shape[1] :], skip_special_tokens=True)
624624
print(decoded_outputs)
625-
```'''
625+
```"""
626626
self.assertEqual(clean_runnable_blocks(text), expected)

0 commit comments

Comments
 (0)