Skip to content

Contributing

Thank you for your interest in contributing to MoltPy.

Development Setup

git clone https://github.com/iolimat/moltpy.git
cd moltpy
uv sync --extra dev

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 annotations at 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:

  1. Create a directory under src/moltpy/modules/<module_name>/
  2. Add manifest.json with metadata
  3. Add templates in templates/
  4. Add snippets in snippets/ if needed
  5. Update core templates for dependencies/settings if needed
  6. Add tests to verify the module renders correctly
  7. Update docs/usage/modules.md with 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_path fixtures 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

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Make your changes
  4. Run the full test suite (uv run pytest)
  5. Run linting and type checking (uv run ruff check . && uv run mypy src/)
  6. Commit your changes
  7. Push to your fork
  8. Open a Pull Request

Code of Conduct

Be respectful, constructive, and inclusive. We are building this tool together.