mgpy treats complexity as a measurable refactoring target: hotspots should be visible, comparable and trackable across baselines.
Key points
- CLI: On Windows the examples use the recommended
py -3.12 -m <module> ...form (for examplepy -3.12 -m manifestguard ...). On Linux/macOS this usually maps topython3.12 -m .... - The built-in AST analyzer is the default engine and keeps trend data stable over time.
- Early returns, smaller helper functions and clearer responsibilities reduce violations faster than formatting-only cleanups.
- Always save a baseline checkpoint before larger structural changes.
Recommended mgpy workflow
- Capture the current hotspots with a fixed threshold first.
- Break the worst functions into smaller, testable steps instead of moving the whole module tree at once.
- After each refactor, compare the result against the stored baseline.
Quick start
py -3.12 -m manifestguard complexity --threshold 12
py -3.12 -m manifestguard baseline --save-label pre-refactor
py -3.12 -m manifestguard baseline --compare pre-refactor