Refactor generate_category_data: extract finalize_category_output#5422
Open
ludeeus wants to merge 3 commits into
Open
Refactor generate_category_data: extract finalize_category_output#5422ludeeus wants to merge 3 commits into
ludeeus wants to merge 3 commits into
Conversation
Pull the summary/validation/diff/output-writing tail of generate_category_data out into a reusable finalize_category_output helper (plus a small _dump_diff helper), and switch the module entrypoint to argparse. Pure refactor with no behavior change: the output files are written with the same options as before. This is preparatory groundwork so the finalization step can later be reused by a merge step. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NL8ieP9vEVJLTZ51esR6VD
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors scripts/data/generate_category_data.py by extracting the “finalization” tail of category generation (summary, validation, diff generation, and output file writes) into a reusable helper, and modernizes the script entrypoint to use argparse. This supports upcoming work to reuse the finalization logic without duplicating it.
Changes:
- Extract output/validation/diff-writing logic into
finalize_category_output()and introduce_dump_diff()to centralize diff JSON formatting. - Update
generate_category_data()to delegate final output handling to the new helper. - Replace manual
sys.argvparsing with anargparse-based CLI entrypoint.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Recreate outputdata/<category>/ and outputdata/diff/ up front in generate_category_data (as before the refactor), so the directories exist even when data generation fails before finalization. The makedirs calls in finalize_category_output are kept (idempotent) so the helper stays self-contained for reuse. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NL8ieP9vEVJLTZ51esR6VD
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
ludeeus
marked this pull request as ready for review
July 23, 2026 17:26
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
Preparatory refactor of
scripts/data/generate_category_data.pywith no behavior change.generate_category_datainto a reusablefinalize_category_output()helper (plus a small_dump_diffhelper).argparse.This is the first of a few small PRs that split the sharding work (previously #5419) into reviewable pieces. Extracting the finalization step here lets a later merge step reuse it without duplicating the logic.
No behavior change
Output files are written with the same options as before (
data.json/stored.jsonunsorted;repositories.jsonkeeps its existing dump; diffs and summary unchanged). Existing snapshot tests cover this and are untouched.🤖 Generated with Claude Code
https://claude.ai/code/session_01NL8ieP9vEVJLTZ51esR6VD
Generated by Claude Code