refactor(logits-processor): move test-only helpers into the test file - #7
Merged
Conversation
The block was labelled "Backward compatibility methods for existing tests" -- four methods shipped in the installed package that nothing in the package ever called: _get_utf8_state pure alias for _analyze_utf8_state _valid_start_bytes hand-listed copy of what mask_start encodes _valid_continuation_bytes only called by _get_allowed_next_bytes _get_allowed_next_bytes set-returning wrapper for the mask lookup _get_utf8_state needed no replacement: tests now call _analyze_utf8_state directly. The other three collapse into one allowed_next_bytes() helper in the test file. That helper reads the masks the processor actually uses, rather than re-listing the valid ranges by hand as _valid_start_bytes did. The start byte tests now assert against the production mask instead of a parallel copy that could drift from it, so they test slightly more than before. Verified: 241 passed, same count as before, no test removed or skipped. No reference to any of the four names remains anywhere in the repo (the one grep hit is test_valid_start_bytes, a test name, still accurate). Nothing on the __call__ path is touched, so no benchmark needed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #6, same file. The block was already labelled "Backward compatibility methods for existing tests" — four methods shipped in the installed package that nothing in the package ever calls.
What
_get_utf8_state_analyze_utf8_state_valid_start_bytesmask_startalready encodes_valid_continuation_bytes_get_allowed_next_bytes_get_allowed_next_bytes_get_utf8_stateneeded no replacement — tests now call_analyze_utf8_statedirectly. The other three collapse into one helper in the test file:−31 lines from the installed package, −66/+49 overall.
This makes the tests slightly stronger
_valid_start_bytesre-listed the valid ranges by hand:...so
test_valid_start_byteswas asserting against a parallel copy of the rules, which could drift frommask_startwithout any test failing. The new helper reads the mask the processor actually uses, so those assertions now cover the production mask.Verification
def test_valid_start_bytes, a test name, still accurate.__call__path is touched, so no benchmark for this one — the deleted methods were never on it.🤖 Generated with Claude Code
Note
Low Risk
Test and dead-code cleanup only;
__call__and mask-building logic are unchanged.Overview
Removes four test-only backward-compat helpers from
UTF8ValidationLogitsProcessor(_get_utf8_state,_valid_start_bytes,_valid_continuation_bytes,_get_allowed_next_bytes) so they are no longer part of the installed package API.Tests now call
_analyze_utf8_statedirectly and use a newallowed_next_byteshelper intest_logits_processor.pythat derives allowed next bytes from the same_get_device_masks/_select_continuation_maskpath as production, instead of hand-listed byte ranges that could drift frommask_start.Reviewed by Cursor Bugbot for commit dc97fc2. Bugbot is set up for automated code reviews on this repo. Configure here.