Contributing to PyWizardry

Help make PyWizardry better for everyone

๐Ÿš€ Getting Started

Prerequisites

  • Python 3.7 or higher
  • Git installed
  • Basic understanding of Python
  • GitHub account

Fork and Clone

# Fork the repository on GitHub
# Visit: https://github.com/saifullah10141/pywizardry

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

# Add upstream remote
git remote add upstream https://github.com/saifullah10141/pywizardry.git

# Create a branch
git checkout -b feature/your-feature-name

Development Setup

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

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

# Install pre-commit hooks
pre-commit install

๐Ÿ“œ Code of Conduct

Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

Our Standards

Examples of behavior that contributes to a positive environment:

  • Using welcoming and inclusive language
  • Being respectful of differing viewpoints and experiences
  • Gracefully accepting constructive criticism
  • Focusing on what is best for the community
  • Showing empathy towards other community members

Examples of unacceptable behavior:

  • The use of sexualized language or imagery
  • Trolling, insulting or derogatory comments
  • Public or private harassment
  • Publishing others' private information without permission
  • Other conduct which could reasonably be considered inappropriate

Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at saifullahanwar00040@gmail.com. All complaints will be reviewed and investigated promptly and fairly.

Enforcement Guidelines:

  1. Correction: Private, written warning
  2. Warning: Public warning with consequences
  3. Temporary Ban: Temporary prohibition from interaction
  4. Permanent Ban: Permanent prohibition from interaction

๐Ÿ’ป Development Guide

Project Structure

pywizardry/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ pywizardry/
โ”‚       โ”œโ”€โ”€ __init__.py      # Main module
โ”‚       โ”œโ”€โ”€ core/            # Core utilities
โ”‚       โ”œโ”€โ”€ files/           # File operations
โ”‚       โ”œโ”€โ”€ strings/         # String utilities
โ”‚       โ”œโ”€โ”€ security/        # Security utilities
โ”‚       โ”œโ”€โ”€ network/         # Network utilities
โ”‚       โ”œโ”€โ”€ data/            # Data processing
โ”‚       โ””โ”€โ”€ async_utils/     # Async utilities
โ”œโ”€โ”€ tests/                   # Test files
โ”œโ”€โ”€ examples/               # Example scripts
โ”œโ”€โ”€ docs/                   # Documentation
โ””โ”€โ”€ scripts/               # Development scripts

Coding Standards

Style Guidelines

  • Follow PEP 8 style guide
  • Use type hints for all functions
  • Write docstrings for all public functions
  • Keep functions focused and single-purpose
  • Maximum line length: 88 characters
  • Use meaningful variable names

Example Contribution

Adding a New Utility Function

"""
New utility function example
"""

from typing import List, Optional
from functools import wraps

def new_utility_function(
    data: List[str],
    option: Optional[str] = None
) -> List[str]:
    """
    Brief description of what the function does.
    
    Args:
        data: List of strings to process
        option: Optional parameter for customization
    
    Returns:
        List[str]: Processed list of strings
    
    Raises:
        ValueError: If input is invalid
    
    Examples:
        >>> new_utility_function(['a', 'b', 'c'])
        ['A', 'B', 'C']
        >>> new_utility_function(['test'], option='upper')
        ['TEST']
    """
    if not data:
        raise ValueError("Data cannot be empty")
    
    # Implementation here
    result = [item.upper() for item in data]
    
    return result

# Add tests in tests/test_module.py
# Update documentation in docs/
# Add examples in examples/

๐Ÿ”€ Pull Request Process

1

Create a Branch

git checkout -b feature/amazing-feature
# or
git checkout -b fix/issue-description
2

Make Your Changes

Implement your feature or fix. Follow coding standards.

3

Run Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=pywizardry --cov-report=html

# Run specific test file
pytest tests/test_your_module.py -v
4

Code Quality Checks

# Format code
black src/pywizardry/

# Check imports
isort src/pywizardry/

# Lint code
flake8 src/pywizardry/

# Type checking
mypy src/pywizardry/
5

Commit Changes

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

- Added new utility function for X
- Improved performance of Y
- Fixed bug in Z

Closes #123"

Commit Message Format:

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation
  • style: Formatting
  • refactor: Code restructuring
  • test: Tests
  • chore: Maintenance
6

Push and Create PR

git push origin feature/amazing-feature

Then create a Pull Request on GitHub with:

  • Clear title and description
  • Reference related issues
  • Add screenshots if applicable
  • Update documentation
7

Review Process

  • CI tests must pass
  • Code review by maintainers
  • Address review comments
  • Update PR if needed

๐Ÿ“š Documentation

Updating Documentation

PyWizardry documentation includes:

1. Docstrings

def example_function(param1: str, param2: int = 10) -> bool:
    """
    Brief description of function.
    
    Extended description explaining details, examples,
    and edge cases.
    
    Args:
        param1: Description of first parameter
        param2: Description of second parameter (default: 10)
    
    Returns:
        bool: Description of return value
    
    Raises:
        ValueError: When something goes wrong
    
    Examples:
        >>> example_function("test", 20)
        True
        >>> example_function("invalid")
        False
    """
    # Function implementation
    return True

2. README Updates

Update README.md with:

  • New features
  • Usage examples
  • Installation instructions
  • Configuration options

3. API Documentation

Update API reference in docs/api/ directory.

๐Ÿงช Testing

Writing Tests

# tests/test_example.py
import pytest
from pywizardry import example_module

def test_basic_functionality():
    """Test basic functionality."""
    result = example_module.example_function("test")
    assert result is True

def test_with_parameters():
    """Test with different parameters."""
    result = example_module.example_function("test", 20)
    assert result is True

def test_edge_cases():
    """Test edge cases."""
    with pytest.raises(ValueError):
        example_module.example_function("")

def test_async_function():
    """Test async functions."""
    import asyncio
    result = asyncio.run(example_module.async_function())
    assert result == expected_value

@pytest.mark.parametrize("input,expected", [
    ("a", "A"),
    ("b", "B"),
    ("c", "C"),
])
def test_parametrized(input, expected):
    """Parametrized test."""
    result = example_module.process(input)
    assert result == expected

Test Coverage

# Generate coverage report
pytest --cov=pywizardry --cov-report=html

# Minimum coverage requirement: 90%
# View report: open htmlcov/index.html

๐ŸŽฏ Areas for Contribution

Bug Fixes

  • Check issue tracker for bugs
  • Reproduce issues
  • Submit fixes with tests

New Features

  • Propose new utilities
  • Discuss in issues first
  • Implement with tests

Documentation

  • Improve docstrings
  • Add examples
  • Fix typos/errors

Performance

  • Optimize slow functions
  • Add benchmarks
  • Improve memory usage

Security

  • Security audits
  • Vulnerability fixes
  • Security improvements

Internationalization

  • Add localization
  • Improve Unicode support
  • Timezone handling