Skip to content

Commit 1d40173

Browse files
committed
Added missing type annotations
1 parent 83d4c19 commit 1d40173

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[flake8]
22
max-line-length = 120
3+
4+
[mypy]
5+
disallow_untyped_defs = true

src/ipping/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def main_udp(args: argparse.Namespace) -> None:
1515
loop.run_until_complete(task)
1616

1717

18-
def main():
18+
def main() -> None:
1919
parser = argparse.ArgumentParser()
2020

2121
subparsers = parser.add_subparsers()

src/ipping/udp.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import random
33
import time
44
from statistics import mean, stdev
5-
from typing import Tuple
5+
from typing import Optional, Tuple
66
from weakref import WeakValueDictionary
77

88
from .protocol import HEADER_SIZE, pack_frame, unpack_frame
@@ -33,7 +33,7 @@ def ping_request(
3333
packet_id: int,
3434
payload_size: int,
3535
response_future: 'asyncio.Future[Tuple[int, Addr]]',
36-
):
36+
) -> None:
3737
self.expected_packets[(client_id, packet_id)] = response_future
3838
frame = pack_frame(client_id, packet_id, payload_size)
3939
self.transport.sendto(frame)
@@ -42,14 +42,14 @@ def connection_made(self, transport: asyncio.DatagramTransport) -> None: # type
4242
self.transport = transport
4343
self.on_connection_made.set_result(True)
4444

45-
def connection_lost(self, exc):
45+
def connection_lost(self, exc: Optional[Exception]) -> None:
4646
self.on_connection_lost.set_result(True)
4747

4848
def datagram_received(self, data: bytes, addr: Addr) -> None:
4949
client_id, packet_id, payload_size = unpack_frame(data)
5050
self.expected_packets[(client_id, packet_id)].set_result((payload_size, addr))
5151

52-
def error_received(self, exc):
52+
def error_received(self, exc: Exception) -> None:
5353
print(f'Request error: {exc}')
5454
# self.on_error_received.set_exception(exc)
5555

@@ -74,7 +74,7 @@ def __init__(
7474

7575
self.loop = loop
7676

77-
async def connect(self):
77+
async def connect(self) -> None:
7878
loop = self.loop or asyncio.get_running_loop()
7979

8080
connection_made = loop.create_future()
@@ -90,12 +90,12 @@ async def connect(self):
9090
remote_addr=self.remote_addr
9191
)
9292

93-
self.transport = transport
94-
self.protocol = protocol
93+
self.transport = transport # type: ignore
94+
self.protocol = protocol # type: ignore
9595

9696
await connection_made
9797

98-
async def stop(self):
98+
async def stop(self) -> None:
9999
self.transport.close()
100100

101101
async def ping_request(self) -> Tuple[int, int, Addr]:

0 commit comments

Comments
 (0)