Skip to content

Contributing

jsem-nerad edited this page Nov 12, 2025 · 5 revisions

Contributing

Thank you for your interest in contributing to strava-cz-python!

Getting Started

1. Fork and Clone

# Fork the repository on GitHub, then:
git clone https://github.com/YOUR-USERNAME/strava-cz-python.git
cd strava-cz-python

2. Set Up Development Environment

Linux / macOS

# Check Python version (3.9+ required)
python3 --version

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

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

Windows

# Check Python version
python --version

# Create virtual environment
python -m venv venv
venv\Scripts\activate

# Install in development mode
pip install -e .[dev]

3. Verify Installation

# Run tests
pytest

# Check code style
black --check src/
flake8 src/

# Type checking
mypy src/

Development Workflow

Create a Feature Branch

git checkout main
git pull origin main
git checkout -b feature/your-feature-name

Make Changes

  1. Write your code in src/strava_cz/
  2. Add tests in tests/
  3. Update documentation if needed
  4. Follow the code style guidelines

Test Your Changes

# Run all tests
pytest

# Run with coverage
pytest --cov=strava_cz --cov-report=term-missing

# Run specific test file
pytest tests/test_strava_cz.py

# Run specific test
pytest tests/test_strava_cz.py::test_function_name

Format Code

# Auto-format with black
black src/ tests/

# Check style with flake8
flake8 src/ tests/

# Type check with mypy
mypy src/

Commit Changes

git add .
git commit -m "feat: add new feature"

# Use conventional commit messages:
# feat: new feature
# fix: bug fix
# docs: documentation changes
# test: test additions or changes
# refactor: code refactoring
# style: formatting changes
# chore: maintenance tasks

Push and Create Pull Request

git push origin feature/your-feature-name

Then create a Pull Request on GitHub.

Code Style Guidelines

Python Style

  • Follow PEP 8
  • Use Black for formatting (line length: 100)
  • Use type hints where appropriate
  • Write docstrings for public functions and classes

Example

from typing import Optional, List


class Example:
    """Brief description of the class.
    
    Longer description if needed.
    
    Attributes:
        attribute: Description of attribute
    """
    
    def __init__(self, value: str):
        """Initialize the example.
        
        Args:
            value: Description of parameter
        """
        self.attribute = value
    
    def method(self, param: int, optional: Optional[str] = None) -> bool:
        """Brief description of method.
        
        Args:
            param: Description of parameter
            optional: Description of optional parameter
            
        Returns:
            Description of return value
            
        Raises:
            ValueError: When something is invalid
        """
        if param < 0:
            raise ValueError("Param must be positive")
        return True

Docstring Format

Use Google-style docstrings:

def function(arg1: str, arg2: int) -> bool:
    """Summary line.
    
    Extended description paragraph.
    
    Args:
        arg1: Description of arg1
        arg2: Description of arg2
        
    Returns:
        Description of return value
        
    Raises:
        ExceptionType: When this happens
    """
    pass

Testing Guidelines

Writing Tests

  • Use pytest for testing
  • Name test files test_*.py
  • Name test functions test_*
  • Use descriptive test names
  • Include docstrings explaining what's being tested

Test Structure

import pytest
from strava_cz import StravaCZ, AuthenticationError


def test_login_success():
    """Test successful login with valid credentials."""
    strava = StravaCZ(username="test", password="test", canteen_number="3753")
    assert strava.user.is_logged_in is True


def test_login_failure():
    """Test login failure with invalid credentials."""
    with pytest.raises(AuthenticationError):
        StravaCZ(username="wrong", password="wrong", canteen_number="3753")


def test_menu_fetch():
    """Test menu fetching and parsing."""
    strava = StravaCZ(username="test", password="test", canteen_number="3753")
    strava.menu.fetch()
    assert len(strava.menu.get_days()) > 0

Test Coverage

  • Aim for >80% code coverage
  • Test both success and failure cases
  • Test edge cases
  • Mock external API calls when appropriate

Documentation Guidelines

Code Documentation

  • Write clear docstrings for all public APIs
  • Include examples in docstrings when helpful
  • Use type hints

Wiki Documentation

  • Update relevant wiki pages when adding features
  • Include examples in documentation
  • Keep documentation in sync with code

README

  • Update README.md for major features
  • Include usage examples
  • Keep feature list current

Adding New Features

Checklist

  • Write code with proper error handling
  • Add comprehensive tests
  • Update docstrings
  • Add type hints
  • Format with Black
  • Pass flake8 and mypy checks
  • Update CHANGELOG.md
  • Update relevant wiki pages
  • Add examples if needed
  • Create pull request with clear description

Feature Template

from typing import Optional


class NewFeature:
    """Description of new feature.
    
    This feature does XYZ and is useful for ABC.
    
    Example:
        >>> feature = NewFeature()
        >>> result = feature.do_something()
        >>> print(result)
    """
    
    def __init__(self, param: str):
        """Initialize the feature.
        
        Args:
            param: Description
        """
        self.param = param
    
    def do_something(self) -> bool:
        """Perform the main action.
        
        Returns:
            True if successful
            
        Raises:
            ValueError: If param is invalid
        """
        # Implementation
        pass

Reporting Bugs

Before Reporting

  1. Check if the bug is already reported in Issues
  2. Verify you're using the latest version
  3. Create a minimal reproducible example

Bug Report Template

**Describe the bug**
A clear description of what the bug is.

**To Reproduce**
Steps to reproduce:
1. Do this
2. Then this
3. See error

**Code Example**
```python
from strava_cz import StravaCZ

strava = StravaCZ(...)
# Minimal code that reproduces the issue
```

**Expected behavior**
What you expected to happen.

**Actual behavior**
What actually happened.

**Error message**
```
Full error traceback
```

**Environment**
- OS: [e.g., Windows 10, Ubuntu 22.04]
- Python version: [e.g., 3.11.0]
- Library version: [e.g., 0.2.0]

**Additional context**
Any other relevant information.

Requesting Features

Feature Request Template

**Feature Description**
Clear description of the feature.

**Use Case**
Why is this feature needed? What problem does it solve?

**Proposed Solution**
How should this feature work?

**Example Usage**
```python
# Example of how the feature would be used
strava.new_feature()
```

**Alternatives**
Other ways this could be implemented.

**Additional Context**
Any other relevant information.

Pull Request Guidelines

PR Checklist

  • Code follows project style guidelines
  • Tests added and passing
  • Documentation updated
  • CHANGELOG.md updated
  • Commits follow conventional commit format
  • PR description is clear and complete

PR Template

## Description
Brief description of changes.

## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update

## Changes Made
- List specific changes
- Be clear and detailed

## Testing
Describe tests added or modified.

## Related Issues
Fixes #123
Relates to #456

## Screenshots (if applicable)
Add screenshots for UI changes.

## Checklist
- [ ] Code formatted with Black
- [ ] Tests pass
- [ ] Documentation updated
- [ ] CHANGELOG updated

Development Tools

Installed with [dev]

  • pytest - Testing framework
  • pytest-cov - Coverage reporting
  • black - Code formatter
  • flake8 - Linter
  • mypy - Type checker
  • types-requests - Type stubs for requests

Configuration Files

  • pyproject.toml - Project metadata and tool configuration
  • .gitignore - Git ignore rules
  • tests/pytest.ini - Pytest configuration (if exists)

Useful Commands

# Format code
black src/ tests/

# Lint code
flake8 src/ tests/

# Type check
mypy src/

# Run tests
pytest

# Run tests with coverage
pytest --cov=strava_cz --cov-report=html

# Run specific test
pytest tests/test_strava_cz.py::test_name -v

# Install in development mode
pip install -e .

# Install with dev dependencies
pip install -e .[dev]

Release Process

(For maintainers)

Version Bumping

  1. Update version in pyproject.toml
  2. Update CHANGELOG.md
  3. Create git tag
  4. Push to GitHub
  5. Create GitHub release
  6. Build and publish to PyPI
# Update version in pyproject.toml
version = "0.3.0"

# Update CHANGELOG.md
# Add new section for version

# Commit changes
git add .
git commit -m "chore: bump version to 0.3.0"

# Create tag
git tag v0.3.0

# Push
git push origin main
git push origin v0.3.0

Community

Communication

  • GitHub Issues - Bug reports and feature requests
  • GitHub Discussions - Questions and general discussion
  • Pull Requests - Code contributions

Code of Conduct

  • Be respectful and inclusive
  • Provide constructive feedback
  • Focus on what's best for the community
  • Show empathy toward others

Questions?

If you have questions about contributing:

  1. Check existing documentation
  2. Search GitHub Issues
  3. Create a new issue with your question

Thank You!

Thank you for contributing to strava-cz-python! Your contributions help make this library better for everyone.

Clone this wiki locally