refactor: reduce codebase by 35% (~12,750 lines removed)#16
Merged
Conversation
…lity - Replace 51 identical choice methods with declarative _choice_fields dict + __init_subclass__ factory - Remove 816 @overload type-stub declarations (1,632 lines) - Remove 36 redundant @Property accessors from core.py (__getattr__ already handles them) - Trim docstrings across all providers, core, schema.py - Trim locale data tuples (names 100->50, cities 100->50, streets 75->40) - Trim provider inline data (40+ entry tuples -> 20) - Merge ai_chat.py into llm.py (pure delegation wrapper) - Remove dead code, comment banners, redundant tests - Strip test docstrings and decorative comments - Pin ruff version, add [tool.ruff] config, add pre-commit - Remove unused TYPE_CHECKING imports from core.py - Reformat test files with ruff format - All 1,869 tests pass; benchmarks show performance-neutral results
05b6d06 to
cf9d053
Compare
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
Reduce the DataForge codebase from ~48,688 lines to ~31,578 lines (35.1% reduction, 12,757 net lines deleted across 160 files) while preserving identical functionality and performance-neutral benchmarks.
Key Changes
_choice_fieldspattern: Replaced 51 identicalself._engine.choice(TUPLE)methods with a class-level dict +__init_subclass__factory inbase.py, eliminating repetitive boilerplate across all 36 providers@overloadstubs: 1,632 lines of type-stub declarations across 272 methods -- pure IDE hint boilerplate with no runtime effect@propertyaccessors fromcore.py:__getattr__already provided dynamic provider accessai_chat.pyintollm.py: AiChatProvider was a pure delegation wrapper holding no data -- all methods now live directly on LlmProviderTesting
test_unique_batchcount reduced from 100->40 to match trimmed city poolPerformance
Benchmarks run against a fresh baseline captured on
mainin the same session (fair comparison):choices()patterns restoredFiles
src/dataforge/providers/ai_chat.py