Skip to content

Commit fb40afc

Browse files
authored
Add @overload to Connection.send() (#161)
1 parent ea01274 commit fb40afc

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

h11/_connection.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# This contains the main Connection class. Everything in h11 revolves around
22
# this.
3-
from typing import Any, Callable, cast, Dict, List, Optional, Tuple, Type, Union
3+
from typing import (
4+
Any,
5+
Callable,
6+
cast,
7+
Dict,
8+
List,
9+
Optional,
10+
overload,
11+
Tuple,
12+
Type,
13+
Union,
14+
)
415

516
from ._events import (
617
ConnectionClosed,
@@ -489,6 +500,14 @@ def next_event(self) -> Union[Event, Type[NEED_DATA], Type[PAUSED]]:
489500
else:
490501
raise
491502

503+
@overload
504+
def send(self, event: ConnectionClosed) -> None:
505+
...
506+
507+
@overload
508+
def send(self, event: Event) -> bytes:
509+
...
510+
492511
def send(self, event: Event) -> Optional[bytes]:
493512
"""Convert a high-level event into bytes that can be sent to the peer,
494513
while updating our internal state machine.

0 commit comments

Comments
 (0)