Contributing¶
Thank you for your interest in contributing to MoltPy.
Development Setup¶
Project Commands¶
# Run tests
uv run pytest
# Run tests with coverage
uv run pytest --cov=moltpy --cov-report=term-missing
# Lint
uv run ruff check .
# Format code
uv run ruff format .
# Type check
uv run mypy src/
# Run the CLI locally
uv run moltpy new
Code Style¶
- Formatter/Linter: ruff, target Python 3.10, line length 100
- Quotes: Double quotes
- Indentation: Spaces (4 spaces)
- Type checking: mypy in strict mode
- Imports: Use
from __future__ import annotationsat the top of every Python file - Typing: All functions and methods must have type hints
- Docstrings: Modules, classes, and public functions should have docstrings
Adding a New Module¶
The easiest way to contribute is by adding a new module:
- Create a directory under
src/moltpy/modules/<module_name>/ - Add
manifest.jsonwith metadata - Add templates in
templates/ - Add snippets in
snippets/if needed - Update core templates for dependencies/settings if needed
- Add tests to verify the module renders correctly
- Update
docs/usage/modules.mdwith the new module
See Custom Modules for detailed module development guide.
Testing¶
MoltPy has a comprehensive test suite covering unit, integration, and end-to-end scenarios.
Test Organization¶
tests/
├── test_builder.py # ProjectBuilder orchestration, env generation, hooks
├── test_cli.py # Click CLI commands and error handling
├── test_config.py # Pydantic model validation
├── test_end_to_end.py # Full generation workflows
├── test_generator.py # ResourceGenerator: CRUD scaffolding, type mapping, injection
├── test_modules.py # Module-specific rendering for all modules
├── test_presets.py # Built-in and user preset management
├── test_registry.py # Module discovery, dependency resolution
├── test_renderer.py # Jinja2 rendering, snippets, static files
└── test_wizard.py # Interactive wizard flows
Testing Guidelines¶
- Use
tmp_pathfixtures for temporary directories - Test both positive and negative cases
- Verify template rendering produces valid output
- Test module dependency resolution and conflict detection
- Mock subprocess calls and external dependencies
- Aim for high coverage on new code
Pull Request Process¶
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Make your changes
- Run the full test suite (
uv run pytest) - Run linting and type checking (
uv run ruff check . && uv run mypy src/) - Commit your changes
- Push to your fork
- Open a Pull Request
Code of Conduct¶
Be respectful, constructive, and inclusive. We are building this tool together.