Skip to content

Commit a31d182

Browse files
committed
Add type annotations to TLSUpgradeProto
1 parent bae282e commit a31d182

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

asyncpg/connect_utils.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -764,14 +764,21 @@ def _parse_connect_arguments(*, dsn, host, port, user, password, passfile,
764764

765765

766766
class TLSUpgradeProto(asyncio.Protocol):
767-
def __init__(self, loop, host, port, ssl_context, ssl_is_advisory):
767+
def __init__(
768+
self,
769+
loop: asyncio.AbstractEventLoop,
770+
host: str,
771+
port: int,
772+
ssl_context: ssl_module.SSLContext,
773+
ssl_is_advisory: bool,
774+
) -> None:
768775
self.on_data = _create_future(loop)
769776
self.host = host
770777
self.port = port
771778
self.ssl_context = ssl_context
772779
self.ssl_is_advisory = ssl_is_advisory
773780

774-
def data_received(self, data):
781+
def data_received(self, data: bytes) -> None:
775782
if data == b'S':
776783
self.on_data.set_result(True)
777784
elif (self.ssl_is_advisory and
@@ -789,7 +796,7 @@ def data_received(self, data):
789796
'rejected SSL upgrade'.format(
790797
host=self.host, port=self.port)))
791798

792-
def connection_lost(self, exc):
799+
def connection_lost(self, exc: typing.Optional[Exception]) -> None:
793800
if not self.on_data.done():
794801
if exc is None:
795802
exc = ConnectionError('unexpected connection_lost() call')

0 commit comments

Comments
 (0)