[CI][RFC] Replace black-jupyter with ruff-format (#37210)

Co-authored-by: Alison Shao <a.shao@wustl.edu>
This commit is contained in:
Alex Nails
2026-09-02 19:46:08 -07:00
committed by GitHub
co-authored by Alison Shao
parent 2641e427be
commit 28262c20df
1411 changed files with 7766 additions and 8176 deletions
@@ -39,7 +39,6 @@ def _make_req(origin_input_ids=None, output_ids=None):
# Serialization round-trip
class TestCustomLogitProcessorSerialization(CustomTestCase):
def test_to_str_produces_valid_json(self):
"""Test that to_str() produces valid JSON with a 'callable' field."""
s = DisallowedTokensLogitsProcessor.to_str()
@@ -53,7 +53,6 @@ def _make_batch(reqs):
# BatchedPenalizerOrchestrator
class TestBatchedPenalizerOrchestrator(CustomTestCase):
def test_init_detects_required_penalizers(self):
"""Test that orchestrator marks is_required=True when any request has nonzero penalty."""
reqs = [_make_req(freq=1.0)]
@@ -143,7 +142,6 @@ class TestBatchedPenalizerOrchestrator(CustomTestCase):
# BatchedFrequencyPenalizer
class TestBatchedFrequencyPenalizer(CustomTestCase):
def _setup(self, freq_values):
reqs = [_make_req(freq=f) for f in freq_values]
batch = _make_batch(reqs)
@@ -225,7 +223,6 @@ class TestBatchedFrequencyPenalizer(CustomTestCase):
# BatchedPresencePenalizer
class TestBatchedPresencePenalizer(CustomTestCase):
def _setup(self, presence_values):
reqs = [_make_req(presence=p) for p in presence_values]
batch = _make_batch(reqs)
@@ -275,7 +272,6 @@ class TestBatchedPresencePenalizer(CustomTestCase):
# BatchedMinNewTokensPenalizer
class TestBatchedMinNewTokensPenalizer(CustomTestCase):
def _setup(self, configs):
"""configs: list of (min_tokens, stop_ids, eos_id)."""
reqs = [_make_req(min_tokens=c[0], stop_ids=c[1], eos_id=c[2]) for c in configs]
@@ -388,7 +384,6 @@ class TestBatchedMinNewTokensPenalizer(CustomTestCase):
# _BatchedPenalizer base class edge cases
class TestBatchedPenalizerBase(CustomTestCase):
def test_filter_when_not_prepared_is_noop(self):
"""Test that filter on an unprepared penalizer does not crash."""
reqs = [_make_req()]
@@ -452,7 +447,6 @@ class TestBatchedPenalizerBase(CustomTestCase):
# Orchestrator with multiple penalizer types
class TestOrchestratorMultiplePenalizers(CustomTestCase):
def test_all_three_penalizers(self):
"""Test orchestrator managing frequency, presence, and min_new_tokens together."""
reqs = [_make_req(freq=1.0, presence=0.5, min_tokens=2, eos_id=2)]
@@ -50,7 +50,6 @@ def _serial_batched_fill(entries, vocab_mask):
class TestMergeBiasTensor(CustomTestCase):
def test_both_none_returns_none(self):
"""Test that merging two None tensors returns None."""
result = merge_bias_tensor(None, None, 2, 3, DEVICE, 0.0)
@@ -95,7 +94,6 @@ class TestMergeBiasTensor(CustomTestCase):
# SamplingBatchInfo.__len__
class TestSamplingBatchInfoLen(CustomTestCase):
def test_len_matches_batch_size(self):
"""Test that __len__ returns batch size (number of temperature rows)."""
info = _make_info(batch_size=5)
@@ -103,7 +101,6 @@ class TestSamplingBatchInfoLen(CustomTestCase):
class TestMergeCustomLogitProcessor(CustomTestCase):
def test_both_none_returns_none(self):
"""Test that merging two None processor dicts returns None."""
result = SamplingBatchInfo.merge_custom_logit_processor(
@@ -150,7 +147,6 @@ class TestMergeCustomLogitProcessor(CustomTestCase):
# apply_logits_bias
class TestApplyLogitsBias(CustomTestCase):
def test_applies_additive_penalties(self):
"""Test that pre-accumulated additive penalties are added to logits."""
info = _make_info(batch_size=1)
@@ -239,8 +235,8 @@ class TestApplyLogitsBias(CustomTestCase):
def make_info():
grammar = MagicMock()
grammar.apply_vocab_mask.side_effect = (
lambda logits, vocab_mask: logits.add_(vocab_mask)
grammar.apply_vocab_mask.side_effect = lambda logits, vocab_mask: (
logits.add_(vocab_mask)
)
info = _make_info(batch_size=1)
info.acc_additive_penalties = torch.linspace(
@@ -272,7 +268,6 @@ class TestApplyLogitsBias(CustomTestCase):
# update_penalties
class TestUpdatePenalties(CustomTestCase):
def test_required_creates_penalties_tensor(self):
"""Test that update_penalties allocates a zero tensor and calls orchestrator methods."""
orch = MagicMock(is_required=True)
@@ -296,7 +291,6 @@ class TestUpdatePenalties(CustomTestCase):
# update_regex_vocab_mask
class TestUpdateRegexVocabMask(CustomTestCase):
def test_no_grammars_clears_mask(self):
"""Test that None grammars clears the grammar_mask."""
info = _make_info(batch_size=1)
@@ -379,7 +373,6 @@ class TestUpdateRegexVocabMask(CustomTestCase):
# filter_batch
class TestFilterBatch(CustomTestCase):
def test_filter_keeps_correct_indices(self):
"""Test that filter retains rows at indices 0 and 2, dropping index 1."""
info = _make_info(batch_size=3)
@@ -434,7 +427,6 @@ class TestFilterBatch(CustomTestCase):
# merge_batch
class TestMergeBatch(CustomTestCase):
def test_merge_concatenates_tensors(self):
"""Test that merge concatenates temperature tensors from both batches."""
info1 = _make_info(batch_size=2)
@@ -513,7 +505,6 @@ class TestMergeBatch(CustomTestCase):
# copy_for_forward
class TestCopyForForward(CustomTestCase):
def test_returns_copy_without_orchestrator(self):
"""Test that copy_for_forward returns a copy with orchestrator set to None."""
orch = MagicMock(is_required=False)
@@ -526,7 +517,6 @@ class TestCopyForForward(CustomTestCase):
# from_schedule_batch
class TestFromScheduleBatch(CustomTestCase):
def setUp(self):
super().setUp()
# from_schedule_batch reads these two flags from the exec bag; give