Thank you for your interest in contributing to StreamWatch! This document provides guidelines and information for contributors.
- Code of Conduct
- Getting Started
- Development Setup
- Coding Standards
- Testing Guidelines
- Submitting Changes
- Issue Reporting
- Feature Requests
By participating in this project, you agree to abide by our Code of Conduct. Please be respectful and constructive in all interactions.
- Fork the repository on GitHub
- Clone your fork locally
- Set up the development environment (see Development Setup)
- Create a new branch for your changes
- Make your changes and test them
- Submit a pull request
Please refer to the Development Setup section in README.md for detailed instructions on setting up your development environment.
# Clone your fork
git clone https://github.com/YOUR_USERNAME/streamwatch-cli.git
cd streamwatch-cli
# Install dependencies
uv sync --dev
# Set up pre-commit hooks
uv run pre-commit install
# Run tests to ensure everything works
uv run pytestWe use several tools to maintain consistent code quality:
- Black for code formatting (line length: 88 characters)
- isort for import sorting (compatible with Black)
- Flake8 for linting and style checking
- MyPy for static type checking
- Bandit for security vulnerability scanning
All code must pass pre-commit hooks before being committed. The hooks will automatically:
- Format code with Black
- Sort imports with isort
- Check code style with Flake8
- Perform type checking with MyPy
- Scan for security issues with Bandit
- Check for common issues (trailing whitespace, large files, etc.)
Run hooks manually:
uv run pre-commit run --all-files- Follow PEP 8 with Black's formatting
- Use type hints for all function parameters and return values
- Write docstrings for all public functions, classes, and modules
- Use descriptive variable names and avoid abbreviations
- Keep functions small and focused on a single responsibility
- Use f-strings for string formatting when possible
from typing import Optional, List
import logging
logger = logging.getLogger(__name__)
def process_stream_url(url: str, alias: Optional[str] = None) -> dict[str, str]:
"""Process a stream URL and return stream information.
Args:
url: The stream URL to process
alias: Optional custom alias for the stream
Returns:
Dictionary containing stream information
Raises:
ValueError: If the URL is invalid
"""
if not url.strip():
raise ValueError("URL cannot be empty")
result = {
"url": url.strip(),
"alias": alias or extract_default_name(url),
}
logger.info(f"Processed stream: {result['alias']}")
return result- Write tests for all new functionality
- Use pytest as the testing framework
- Use pytest-mock for mocking external dependencies
- Aim for high test coverage (target: >90%)
- Write both unit tests and integration tests
import pytest
from unittest.mock import Mock, patch
from streamwatch.core import StreamProcessor
class TestStreamProcessor:
"""Test cases for StreamProcessor class."""
def test_process_valid_url(self):
"""Test processing a valid stream URL."""
processor = StreamProcessor()
result = processor.process("https://twitch.tv/example")
assert result["url"] == "https://twitch.tv/example"
assert "alias" in result
@patch("streamwatch.core.requests.get")
def test_process_url_with_network_error(self, mock_get):
"""Test handling network errors during URL processing."""
mock_get.side_effect = ConnectionError("Network error")
processor = StreamProcessor()
with pytest.raises(ConnectionError):
processor.process("https://twitch.tv/example")# Run all tests
uv run pytest
# Run with coverage report
uv run pytest --cov=src/streamwatch --cov-report=html
# Run specific test file
uv run pytest tests/test_stream_utils.py
# Run tests matching a pattern
uv run pytest -k "test_process"-
Create a feature branch from
main:git checkout -b feature/your-feature-name
-
Make your changes following the coding standards
-
Add or update tests for your changes
-
Ensure all tests pass:
uv run pytest uv run pre-commit run --all-files
-
Commit your changes with a clear commit message:
git commit -m "Add feature: brief description of changes" -
Push to your fork and create a pull request
- Use the present tense ("Add feature" not "Added feature")
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters or less
- Reference issues and pull requests liberally after the first line
- Provide a clear description of the changes
- Link to related issues using keywords (e.g., "Fixes #123")
- Include screenshots for UI changes
- Update documentation if necessary
- Ensure CI passes before requesting review
When reporting bugs, please include:
- StreamWatch version (
streamwatch --version) - Python version (
python --version) - Operating system and version
- Steps to reproduce the issue
- Expected behavior vs actual behavior
- Error messages or logs (if any)
- Configuration files (if relevant, remove sensitive data)
When requesting features:
- Check existing issues to avoid duplicates
- Describe the use case and why the feature would be valuable
- Provide examples of how the feature would work
- Consider implementation complexity and maintenance burden
If you have questions about contributing, feel free to:
- Open an issue with the "question" label
- Start a discussion in the GitHub Discussions tab
- Contact the maintainers directly
Thank you for contributing to StreamWatch! 🎉