Contributing to PyGnome
Thank you for your interest in contributing to PyGnome! This document provides guidelines and instructions for contributing to the project.
Getting Started
Prerequisites
- Python 3.9 or higher
- Git
- A GitHub account
Setting Up the Development Environment
- Fork the repository on GitHub
- Clone your fork locally:
- Set up a virtual environment:
- Install the package in development mode:
- Install development dependencies:
Development Workflow
Branching Strategy
main
: The main development branchfeature/*
: Feature branchesbugfix/*
: Bug fix branchesrelease/*
: Release branches
Creating a New Feature or Bug Fix
- Create a new branch from
main
: - Make your changes
- Run tests to ensure your changes don't break existing functionality:
- Commit your changes:
- Push your branch to your fork:
- Create a pull request on GitHub
Coding Standards
Python Code Style
- Use type hints in function and method signatures
- Use the new way of defining types (e.g.,
dict
,list
,| None
,any
) - Write short but informative docstrings
- Use
Path
frompathlib
instead ofstr
/import os
for file operations - Use Pydantic classes or dataclasses instead of
dict
structures - Use
Enum
objects instead of hard-coded string values - Remove unused imports
- Sort functions and methods alphabetically (except underscores)
- Keep files under 500 lines; refactor if they get too long
- Write classes (and enums) in their own files whenever possible
Testing
- Write unit tests for all new functionality
- Place test files in the
tests
directory - Use Python's built-in
unittest
framework - Run tests using the provided script:
Documentation
- Update documentation for any changes to the API
- Write clear and concise documentation
- Include examples where appropriate
- Use markdown for documentation files
Pull Request Process
- Ensure your code follows the coding standards
- Update the documentation as necessary
- Add or update tests as necessary
- Ensure all tests pass
- Submit your pull request
- Address any feedback from reviewers
Release Process
- Update the version number in
pyproject.toml
- Update the changelog
- Create a new release branch:
release/vX.Y.Z
- Create a pull request to merge the release branch into
main
- Once the pull request is approved and merged, create a new release on GitHub
- Tag the release with the version number
- Publish the package to PyPI