Contributing
Thank you for your interest in contributing to promptprep! This guide will help you get started with contributing to the project.
Getting Started
Prerequisites
Before you begin, ensure you have the following:
Python 3.10 or higher
Git
A GitHub account
Setting Up the Development Environment
Fork the repository on GitHub:
Click the “Fork” button in the top-right corner
Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/promptprep.git cd promptprep
Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
Install the package in development mode with all development dependencies:
pip install -e ".[dev]"
Set up the upstream remote:
git remote add upstream https://github.com/kartikmandar/promptprep.git
Development Workflow
Create a new branch for your feature or bugfix:
git checkout -b feature-name
Make your changes to the codebase.
Run the tests to ensure your changes don’t break existing functionality:
pytest
Format your code with Black:
black .Run the linter to check for code quality issues:
ruff check .
Commit your changes with a descriptive message:
git add . git commit -m "Add feature X" or "Fix bug Y"
Push your changes to your fork:
git push origin feature-name
Create a pull request on GitHub:
Visit your fork at https://github.com/YOUR-USERNAME/promptprep
Click “Compare & pull request”
Fill out the pull request template with details about your changes
Code Style Guidelines
We follow these coding standards:
PEP 8: The Python style guide, with some modifications as defined in our Black configuration.
Black: We use Black for code formatting with a line length of 88 characters.
Docstrings: We use Google-style docstrings for all public functions, classes, and methods.
Example of a well-formatted function with docstring:
def process_file(file_path, include_comments=True, summary_mode=False):
"""Process a single file and return its content.
Args:
file_path (str): Path to the file to process.
include_comments (bool, optional): Whether to include comments. Defaults to True.
summary_mode (bool, optional): Whether to extract only signatures and docstrings.
Defaults to False.
Returns:
str: The processed content of the file.
Raises:
FileNotFoundError: If the file doesn't exist.
PermissionError: If the file can't be read.
"""
# Implementation here...
Testing Guidelines
We use pytest for testing. All new features should include tests, and all bug fixes should include tests that verify the fix.
Test Location: Tests should be placed in the tests/ directory with a filename that matches the module being tested, prefixed with test_.
Test Coverage: We aim for high test coverage. Use pytest-cov to check coverage:
pytest --cov=promptprep
Test Types:
Unit Tests: Test individual functions and classes in isolation.
Integration Tests: Test how components work together.
Functional Tests: Test the CLI and end-to-end functionality.
Documentation Guidelines
We use Sphinx for documentation. All new features should be documented.
Docstrings: All public functions, classes, and methods should have Google-style docstrings.
RST Files: Feature documentation should be added to the appropriate RST file in the docs/source/ directory.
Building Docs: You can build the documentation locally to preview your changes:
cd docs make html # Open build/html/index.html in your browser
README Updates: If your changes affect the basic usage or installation, update the README.md file as well.
Pull Request Process
Create a Focused PR: Each pull request should address a single feature or bug fix.
Write a Clear Description: Explain what your changes do and why they’re needed.
Include Tests: Ensure your changes are covered by tests.
Update Documentation: Add or update documentation for your changes.
Pass CI Checks: Make sure all CI checks pass before requesting a review.
Address Review Feedback: Be responsive to review feedback and make requested changes.
Squash Commits: Before merging, squash your commits into a single, well-described commit.
Release Process
The project maintainers follow these steps for releases:
Update the version number in pyproject.toml using bump-my-version.
Update the changelog with the new version and its changes.
Create a new release on GitHub with release notes.
Publish the new version to PyPI.
Getting Help
If you need help with contributing:
Open an issue on GitHub with your question
Reach out to the maintainers directly
Thank you for contributing to promptprep!