refactor: move preset command handlers to presets/_commands.py (PR-6/8)#2826
Open
darion-yaphet wants to merge 2 commits into
Open
refactor: move preset command handlers to presets/_commands.py (PR-6/8)#2826darion-yaphet wants to merge 2 commits into
darion-yaphet wants to merge 2 commits into
Conversation
Pure structural move to mirror integrations/. presets.py becomes presets/__init__.py with relative imports rebased one level deeper. No behavior change; public import surface (from .presets import ...) preserved. Prepares for co-locating preset command handlers in PR-6/8.
Cut the preset_app / preset_catalog_app Typer groups and all 12 command handlers out of __init__.py into presets/_commands.py, exposing register(app) — mirrors the integration co-location from PR-5. __init__.py now registers via _register_preset_cmds(app), dropping ~620 lines (3282 -> 2663). Handlers lazy-import root helpers (_require_specify_project, get_speckit_version, _locate_bundled_preset, _display_project_path) via 'from .. import' so test monkeypatching of specify_cli.<helper> keeps working. _locate_bundled_preset kept as an explicit re-export in __init__.py for that resolution path. CLI surface and public imports unchanged. Full suite: 3162 passed, 40 skipped.
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
PR-6 of the
__init__.pysplit (continues PR-5's integration co-location). Moves thepresetcommand group out ofsrc/specify_cli/__init__.pyinto a co-locatedpresets/_commands.py, trimming__init__.pytoward a thin registration layer.Two commits:
presets.py→presets/package — pure structural move so command handlers can live beside the preset domain logic (mirrorsintegrations/).presets.pybecomespresets/__init__.py; package-relative imports rebased one level deeper. Public import surface (from specify_cli.presets import ...) unchanged.presets/_commands.py— thepreset_app/preset_catalog_appTyper groups and all 12 handlers (list,add,remove,search,resolve,info,set-priority,enable,disable,catalog list/add/remove) move out;__init__.pyregisters them via_register_preset_cmds(app).__init__.pydrops ~620 lines in the preset region.Design notes
_require_specify_project,get_speckit_version,_locate_bundled_preset,_display_project_path) viafrom .. importinside each function, so test monkeypatching ofspecify_cli.<helper>keeps working — same pattern PR-5 used._locate_bundled_presetkept as an explicit re-export in__init__.pyfor that resolution path.Test plan
python -c "import specify_cli"— OKspecify preset --help— full command surface intactuvx ruff check src/— All checks passed