630:P3 [Data Clumps / Argument Spaghetti] in generation flow -> refactor toward Parameter Object#4
Open
not-sure-ksharma12 wants to merge 16 commits into
Conversation
Closes #3 - Runs pytest with coverage on push to main, PRs, and manual dispatch - Tests across Python 3.8, 3.9, 3.10, 3.11, 3.12 - Uploads coverage report as artifact for the 3.12 run - Includes self-review documentation
Closes #2 - Tests for --version, --help, --cli, --gui flag parsing - Tests for CLI flag routing to project_generator.main() - Tests for argument forwarding to the CLI module - Tests for graceful handling when wxPython is unavailable - Tests for module execution and callable verification
Closes #6 - Tests that each feature flag (cli, tests, pypi_packaging, readme, etc.) creates expected files - Tests that disabled flags do not create files - Tests for feature combinations working together - Tests for metadata injection (author, email, version, description) - Tests for no unresolved placeholder patterns in generated output
Closes #5 - Parametrized tests verify every template generates successfully - Parametrized tests verify every template creates a non-empty project directory - Parametrized tests verify every template has required metadata fields - Template-specific structure tests for Flask, FastAPI, data-science, CLI tool, binary-extension, namespace-package, and plugin-framework - project_generator.py coverage improved from 31% to 53%
## Summary of changes - Validate paths in `_update_file_content` with `resolve()` and containment under the project root (`relative_to`) before read/write. - Pass `project_path` from `_update_package_references` for both text files and `*.py` updates. - Added tests: a traversal-style path must not be written; an in-tree file still gets replacements. ## Verification - `PYTHONPATH=src pytest tests/ -q` — all tests pass. ## Evidence - Addresses Sonar **pythonsecurity:S2083** by refusing I/O when the resolved path leaves the project directory. - Regression tests document safe vs unsafe paths.
* Harden _update_file_content against path traversal (S2083) - Resolve project root and target; require target under root via relative_to - Rebuild I/O path as root_resolved.joinpath(*rel.parts) after containment (Sonar S2083) - Skip updates with warning when path escapes project directory - Add regression tests for outside vs in-tree paths * Refine safe path handling for _update_file_content - Replace joinpath(*rel.parts) with stepwise root/segment joins; reject '..' - Perform read/write via path.open() after containment check
Closes #20 ## Summary of changes - Replaced bare `except:` around `ImageFont.truetype` with `except Exception:` so `SystemExit` and `KeyboardInterrupt` are not swallowed (python:S5754). ## Verification - `PYTHONPATH=src pytest tests/ -q` — all tests pass. - `pip install pillow` then `python scripts/create_icon.py` — icon generation runs; falls back to default font if the macOS font path is missing. ## Evidence - Matches python:S5754: no blanket `BaseException` handler for this block.
Early returns plus _clear_template_info_display and _apply_template_detailed_info; same widget updates and layout behavior as before.
Move core tree and scripts/ preview lines into _log_preview_core_structure and _log_preview_scripts_section; same log output order and strings.
Single module-level function; add test that import and calls do not raise.
- Add optional templates_cache_dir to TemplateManager; default unchanged (Path.home()/.python-project-generator/templates). - Forward optional templates_cache_dir from ProjectGenerator. - Add tests for default path, injected temp dir, and forwarding. Closes #36
- Add frozen _FeatureRemovalRule entries and _FEATURE_REMOVAL_POLICY - Drive _remove_unwanted_features from the rule table only - Preserve patterns, dirs, order, and features.get defaults Closes #37
Import Union used by TemplateManager and ProjectGenerator type annotations to restore test collection.
Introduce _ProjectGenerationContext to group repeated internal generation parameters and pass context through core helper methods while preserving public API behavior.
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.
Closes #35
Summary
_ProjectGenerationContextto group repeated generation-flow parameters._apply_optional_scripts_apply_common_docs_update_package_references_customize_projectand_generate_builtin_project.Why
This reduces argument clumps and makes internal generation flow easier to maintain without changing public APIs.
Behavior compatibility
generate_project) unchanged.Verification