refactor: drop unused constants, Bytes1, and BaseUint.to_bytes override#750
Merged
Merged
Conversation
Four audit deletions bundled together. - snappy MAX_VARINT_LENGTH constant: unused anywhere in src or tests. - snappy BLOCK_LOG constant: referenced once as 1 << BLOCK_LOG; inlined into BLOCK_SIZE = 1 << 16. The 64 KB rationale already lives in the BLOCK_SIZE docstring. - Bytes1 type: only appearance outside its own definition was one parametrize case in test_byte_arrays. Class, public re-export, and test case all gone. - BaseUint.to_bytes override: production code passes length and byteorder explicitly at every call site, so nothing relied on the Uint-aware defaults. The override and its three dedicated tests (test_to_bytes_default, test_to_bytes_specifics, test_to_bytes_overflow) all leave; the only remaining .to_bytes caller in encode_bytes already passes its arguments explicitly, and now resolves to int.to_bytes directly. Literal and SupportsIndex imports also drop since they were only used by the override signature. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Four audit deletions bundled together. Net −63 / +2 across 6 files.
snappy/constants.py—MAX_VARINT_LENGTHremoved (no references anywhere).BLOCK_LOGinlined intoBLOCK_SIZE = 1 << 16(its single use); the 64 KB rationale already lives in theBLOCK_SIZEdocstring.types/byte_arrays.py+types/__init__.py+ tests —Bytes1deleted. The only consumer outside its own definition was oneparametrizecase intest_byte_arrays.py; class, public re-export, and test case all gone.types/uint.py+ tests —BaseUint.to_bytesoverride deleted. Production code (encode_bytes,xmss/prf.py) passeslengthandbyteorderexplicitly at every call site, so nothing relied on the Uint-aware defaults. The three orphaned tests (test_to_bytes_default,test_to_bytes_specifics,test_to_bytes_overflow) leave with the override — they only existed to verify its defaults.LiteralandSupportsIndeximports dropped (only the override used them).Skipped: StateT/BlockT TypeVars
The audit's fifth item (
forks/lstar/store.py:7,24-28) was already addressed by merged PR #744 (PEP 695 generic syntax). The current__all__is["AttestationSignatureEntry", "Store"]and there are no module-levelStateT/BlockTdefinitions.Test plan
ruff check— clean on all six files.uv run pytest tests/lean_spec/snappy/ tests/lean_spec/types/test_uint.py tests/lean_spec/types/test_byte_arrays.py— 496 tests pass.grep -rn "MAX_VARINT_LENGTH\|BLOCK_LOG\|Bytes1"acrosssrc/,tests/,packages/— only the expectedBytes16/Bytes12substring matches remain.🤖 Generated with Claude Code