Contribution Guidelines
Relevant source files
The following files were used as context for generating this wiki page:
Uvicorn is a lightning-fast ASGI server implementation designed to run asynchronous web applications. These contribution guidelines outline the technical requirements, development environment setup, and quality standards for maintaining the project's performance and reliability as the "lightning-fast" ASGI server.
The project emphasizes strict validation, high test coverage, and support for modern Python versions (3.10 through 3.14). Contributions range from core protocol implementations (HTTP/1.1 and WebSockets) to documentation and deployment tooling.
Sources: README.md:1-25, pyproject.toml:13-35, mkdocs.yml:64-70
Development Environment Setup
Uvicorn uses hatchling as its build backend and uv for dependency management. The development environment is categorized into specific dependency groups to ensure consistency across different types of contributions.
Dependency Groups
| Group | Purpose | Key Packages |
|---|---|---|
dev | Core development and testing | pytest, ruff, mypy, coverage, httpx |
standard | Optional high-performance extras | uvloop, httptools, watchfiles, websockets |
docs | Documentation building | mkdocs, mkdocs-material, mkdocstrings-python |
Sources: pyproject.toml:1-5, pyproject.toml:44-88
Tools and Configuration
- Linting & Formatting: Managed by
ruffwith a line-length limit of 120. Standard select rules includeE,F,I,FA, andUP. - Type Checking: Managed by
mypy. The project uses strict redundancy checks (warn_redundant_casts) but allows some flexibility on untyped definitions. - Testing: Orchestrated by
pytestwithpytest-xdistfor parallel execution (defaulting to 8 workers).
Sources: pyproject.toml:102-120, pyproject.toml:122-130
Code Quality and Testing Standards
The project enforces a strict 100% test coverage policy for most modules. Any new feature or bug fix must be accompanied by relevant tests.
Coverage Requirements
The coverage report is configured to fail if the overall percentage drops below 100. Certain platform-specific modules (like Windows-specific reloader logic) are omitted when running on non-Windows platforms to maintain this requirement.
The testing flow ensures that every change maintains the project's rigorous stability standards.
Sources: pyproject.toml:138-150, pyproject.toml:152-162
Performance Benchmarking
Because Uvicorn is marketed as "lightning-fast," performance is a critical metric. The project utilizes pytest-codspeed for performance tracking to ensure that changes do not introduce regressions in request handling speeds.
Sources: pyproject.toml:67, README.md:21-30
Documentation Standards
Documentation is built using MkDocs with the material theme. Technical writers and contributors should follow the established structure in mkdocs.yml.
Documentation Features
- Strict Validation: The project uses
strict: truefor MkDocs, meaning broken links or unrecognized references will cause build failures. - Custom Extensions: Support for Mermaid diagrams, code annotations, and pymdownx snippets is enabled.
- Navigation Structure: New features should be documented under appropriate sections: Settings, Server Behavior, Concepts (ASGI, Lifespan, Logging, WebSockets), or Deployment.
Sources: mkdocs.yml:10-45, mkdocs.yml:95-108
Protocol Implementation and Compatibility
Contributors working on core protocols must adhere to the ASGI specification. Uvicorn supports:
- HTTP/1.1: Handled by
h11orhttptools. - WebSockets: Handled by
websockets,wsproto, or a sans-io implementation. - ASGI Versions: Support for spec version 2.3 and 2.4.
The diagram shows the interaction between the server, the underlying protocol implementation, and the ASGI application.
Sources: README.md:32-40, CHANGELOG.md:100-110, CHANGELOG.md:230-240
Conclusion
Contributing to Uvicorn requires a commitment to high-performance asynchronous programming and rigorous testing. By following these guidelines, contributors ensure that Uvicorn remains a reliable, interoperable, and fast ASGI server for the Python ecosystem.
Sources: README.md:85-100