Skip to content

Commit

Permalink
Add @overload to Connection.send() (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Jul 8, 2023
1 parent ea01274 commit fb40afc
Showing 1 changed file with 20 additions and 1 deletion.
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

0 comments on commit fb40afc

Please sign in to comment.