Contributing to mywheelΒΆ

Thank you for your interest in contributing to mywheel! This document provides guidelines and instructions for contributing to this project.

🀝 How to Contribute¢

Reporting IssuesΒΆ

Before creating an issue, please:

  1. Check if the issue already exists in GitHub Issues

  2. Use an appropriate issue template

  3. Include:

    • Python version

    • Operating system

    • Minimal reproducible example

    • Expected vs actual behavior

Submitting Pull RequestsΒΆ

We welcome pull requests! Here’s the process:

  1. Fork the repository

  2. Create a branch for your changes: git checkout -b feature/your-feature

  3. Make your changes following the guidelines below

  4. Test thoroughly (see Testing section)

  5. Submit a PR with a clear description

πŸ› οΈ Development SetupΒΆ

PrerequisitesΒΆ

  • Python 3.8 or higher

  • Git

  • Virtual environment (recommended)

InstallationΒΆ

# Clone your fork
git clone https://github.com/YOUR_USERNAME/mywheel.git
cd mywheel

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode with testing dependencies
pip install -e ".[testing]"

# Install pre-commit hooks
pre-commit install

Project StructureΒΆ

mywheel/
β”œβ”€β”€ src/mywheel/       # Source code
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ robin.py        # Round-robin implementation
β”‚   β”œβ”€β”€ dllist.py       # Doubly-linked list
β”‚   β”œβ”€β”€ bpqueue.py      # Bounded priority queue
β”‚   β”œβ”€β”€ map_adapter.py  # List-to-map adapter
β”‚   └── array_like.py  # Array-like utilities
β”œβ”€β”€ tests/             # Test suite
β”‚   β”œβ”€β”€ conftest.py
β”‚   └── test_*.py
β”œβ”€β”€ docs/              # Sphinx documentation
└── AGENTS.md          # Guidelines for agentic contributors

πŸ“ Code Style GuidelinesΒΆ

General PrinciplesΒΆ

  • Follow existing patterns: The codebase uses consistent patterns (see AGENTS.md)

  • Type hints required: All public APIs must have type hints

  • Memory efficiency: Use __slots__ for classes with fixed attributes

  • Docstrings: Google/NumPy-style with doctest examples

Specific RulesΒΆ

  1. Imports: Standard β†’ Third-party β†’ Local package

    from typing import Generic, TypeVar
    from hypothesis import given
    from mywheel import Dllist
    
  2. Naming:

    • Classes: PascalCase

    • Functions/Methods: snake_case

    • Private: _leading_underscore

  3. Error Handling:

    • Use assert for invariants and preconditions

    • Raise specific exceptions (IndexError, NotImplementedError, StopIteration)

    • Use id() for object identity comparisons

  4. Circular References:

    # Self-referential initialization
    self.next = self
    
    # Identity checks
    if id(self.next) == id(self):
    

Before CommittingΒΆ

# Format code
black .
isort .

# Run linters
flake8 src/mywheel

# Type check
mypy src/mywheel

# Run tests
pytest tests/

# Run all checks at once
pre-commit run --all-files

πŸ§ͺ TestingΒΆ

Running TestsΒΆ

# All tests with coverage
pytest

# Specific test file
pytest tests/test_dllist.py

# Specific test
pytest tests/test_robin.py::test_slnode

# Verbose output
pytest -v

# Pattern matching
pytest -k "test_dllist"

# In isolated environment (tox)
tox

Writing TestsΒΆ

  • Unit tests: Use pytest for specific functionality

  • Property tests: Use hypothesis for data structure invariants

  • Coverage: Maintain 100% coverage for new code

  • Test structure:

    # Standard pytest test
    def test_feature():
        assert expected == actual
    
    # Property-based test
    @given(st.integers(min_value=1, max_value=100))
    def test_property(value):
        assert invariant_holds(value)
    

Test NamingΒΆ

  • Test classes: Test<ClassName>, Test<ClassName>Properties

  • Test functions: test_<feature>, test_<behavior>

πŸ“š DocumentationΒΆ

DocstringsΒΆ

Use Google/NumPy-style docstrings for all public APIs:

def method(self, param: int) -> str:
    """
    Brief description.

    Detailed description of what the method does.

    Args:
        param: Description of param

    Returns:
        Description of return value

    Raises:
        IndexError: When param is out of range

    Examples:
        >>> obj.method(5)
        'result'
    """

Module DocumentationΒΆ

Each module should have a module-level docstring explaining:

  • Purpose of the implementation

  • Key algorithms used

  • Performance characteristics

  • Usage examples

πŸ”„ Code Review ProcessΒΆ

Before Submitting PRΒΆ

  1. βœ… All tests pass locally

  2. βœ… Type checking passes (mypy)

  3. βœ… Linting passes (flake8)

  4. βœ… Code formatted with black and isort

  5. βœ… New code has tests

  6. βœ… Docstrings updated

  7. βœ… AGENTS.md updated if adding new patterns

During ReviewΒΆ

  • Be responsive: Address review feedback promptly

  • Explain changes: Provide rationale for significant decisions

  • Be patient: Reviewers volunteer their time

After MergeΒΆ

  • Your contribution will be credited in release notes

  • Thank you for helping improve mywheel!

πŸš€ Release ProcessΒΆ

Releases are managed by maintainers:

  1. Version updated via setuptools_scm (git tags)

  2. Changelog updated in CHANGELOG.md

  3. Built and published to PyPI via CI

πŸ’¬ Getting HelpΒΆ

  • GitHub Issues: For bugs and feature requests

  • Discussions: For questions and general discussions

  • Documentation: Read <AGENTS.md> for codebase patterns

πŸ“„ LicenseΒΆ

By contributing, you agree that your contributions will be licensed under the .


Thank you for contributing to mywheel! πŸŽ‰