Skip to content

Conversation

@Kludex
Copy link
Owner

@Kludex Kludex commented Sep 14, 2025

No description provided.

@Kludex Kludex requested a review from Copilot September 27, 2025 15:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a base HTTPProtocol class to eliminate code duplication between the two HTTP protocol implementations (HttpToolsProtocol and H11Protocol). It extracts common initialization logic, attributes, and the connection_made method into the base class.

  • Defines a new base HTTPProtocol class with shared initialization logic and common attributes
  • Refactors existing protocol classes to inherit from HTTPProtocol instead of asyncio.Protocol
  • Updates transport parameter types from asyncio.Transport to asyncio.BaseTransport for better type safety

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
uvicorn/protocols/http/base.py Defines the new HTTPProtocol base class with shared attributes and initialization
uvicorn/protocols/http/httptools_impl.py Refactors HttpToolsProtocol to inherit from HTTPProtocol and removes duplicated code
uvicorn/protocols/http/h11_impl.py Refactors H11Protocol to inherit from HTTPProtocol and removes duplicated code
uvicorn/protocols/utils.py Updates transport parameter types to asyncio.BaseTransport
uvicorn/_types.py Simplifies ASGI3Application type definition formatting
uvicorn/logging.py Simplifies tuple unpacking formatting
tests/protocols/test_http.py Updates test infrastructure to work with the new base class and type annotations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

"client",
# Per-request state
"scope",
"headers",
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The __slots__ declaration is missing the scheme attribute that is defined and used in the __init__ method and child classes. This could lead to runtime errors when trying to access the scheme attribute.

Suggested change
"headers",
"headers",
"scheme",

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants