Contributing¶
Thank you for your interest in contributing to pywhatwgurl! This guide will help you get started.
Getting Started¶
Prerequisites¶
- Python 3.10 or higher
- uv (recommended) or pip
- Git
Setting Up the Development Environment¶
-
Fork and clone the repository
-
Install dependencies
-
Install pre-commit hooks
-
Run tests to verify setup
Development Workflow¶
Creating a Branch¶
Create a branch for your work:
Making Changes¶
- Write your code following our style guidelines
- Add or update tests as needed
- Update documentation if applicable
- Run the test suite
Running Tests¶
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=pywhatwgurl
# Run specific test file
uv run pytest tests/test_url.py
# Run conformance tests only
uv run pytest tests/conformance/
Code Style¶
We use Ruff for linting and formatting:
# Check for issues
uv run ruff check .
# Auto-fix issues
uv run ruff check --fix .
# Format code
uv run ruff format .
Pre-commit hooks will run these checks automatically before each commit.
Submitting Changes¶
Commit Messages¶
Write clear, concise commit messages:
feat: add support for blob URLs
fix: handle empty port correctly
docs: update installation guide
test: add edge case tests for IPv6
Prefixes:
- feat: - New feature
- fix: - Bug fix
- docs: - Documentation only
- test: - Tests only
- refactor: - Code refactoring
- chore: - Maintenance tasks
Pull Requests¶
- Push your branch to your fork
- Open a Pull Request against
master - Fill out the PR template
- Wait for review
Types of Contributions¶
Bug Reports¶
Found a bug? Please open an issue with:
- Python version
- pywhatwgurl version
- Minimal reproduction code
- Expected vs actual behavior
Feature Requests¶
Have an idea? Open an issue describing:
- The problem you're trying to solve
- Your proposed solution
- Any alternatives you've considered
Documentation¶
Documentation improvements are always welcome:
- Fix typos or unclear explanations
- Add examples
- Improve API documentation
Code Contributions¶
Before starting significant work, please open an issue to discuss your approach.
Testing Guidelines¶
Test Structure¶
- Unit tests go in
tests/ - Conformance tests go in
tests/conformance/ - Use descriptive test names
Writing Tests¶
def test_url_parsing_with_port():
"""URL should correctly parse port from URL string."""
url = URL("https://example.com:8080/path")
assert url.port == "8080"
assert url.hostname == "example.com"
Conformance Tests¶
When adding features, ensure they pass WPT conformance tests. Add new test data if the WPT suite doesn't cover your case.
Documentation Guidelines¶
Building Docs Locally¶
# Install docs dependencies
uv sync --group docs
# Serve docs locally
uv run mkdocs serve
# Build docs
uv run mkdocs build
Writing Documentation¶
- Use clear, simple language
- Include code examples
- Link to related sections
- Keep the user's perspective in mind
Questions?¶
- Open a GitHub Discussion
- Check existing issues and PRs
Thank you for contributing! 🎉