Skip to content

Add @overload to Connection.send() #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion h11/_connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# This contains the main Connection class. Everything in h11 revolves around
# this.
from typing import Any, Callable, cast, Dict, List, Optional, Tuple, Type, Union
from typing import (
Any,
Callable,
cast,
Dict,
List,
Optional,
overload,
Tuple,
Type,
Union,
)

from ._events import (
ConnectionClosed,
Expand Down Expand Up @@ -489,6 +500,14 @@ def next_event(self) -> Union[Event, Type[NEED_DATA], Type[PAUSED]]:
else:
raise

@overload
def send(self, event: ConnectionClosed) -> None:
...

@overload
def send(self, event: Event) -> bytes:
...

def send(self, event: Event) -> Optional[bytes]:
"""Convert a high-level event into bytes that can be sent to the peer,
while updating our internal state machine.
Expand Down