Skip to content

Commit 941c31b

Browse files
committed
lint and doc
1 parent 052e6dc commit 941c31b

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
(_py_class_role, 'HttpWebServerBasePlugin'),
268268
(_py_class_role, 'multiprocessing.context.Process'),
269269
(_py_class_role, 'multiprocessing.synchronize.Lock'),
270+
(_py_class_role, 'NonBlockingQueue'),
270271
(_py_class_role, 'paramiko.channel.Channel'),
271272
(_py_class_role, 'proxy.http.parser.parser.T'),
272273
(_py_class_role, 'proxy.plugin.cache.store.base.CacheStore'),

proxy/common/backports.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import time
1212
import threading
1313

14-
from typing import Any
14+
from typing import Any, Deque
1515
from queue import Empty
1616
from collections import deque
1717

@@ -94,25 +94,25 @@ class NonBlockingQueue:
9494
Here because proxy.py still supports 3.6
9595
'''
9696

97-
def __init__(self):
98-
self._queue = deque()
99-
self._count = threading.Semaphore(0)
97+
def __init__(self) -> None:
98+
self._queue: Deque[Any] = deque()
99+
self._count: threading.Semaphore = threading.Semaphore(0)
100100

101-
def put(self, item):
101+
def put(self, item: Any) -> None:
102102
'''Put the item on the queue.'''
103103
self._queue.append(item)
104104
self._count.release()
105105

106-
def get(self):
106+
def get(self) -> Any:
107107
'''Remove and return an item from the queue.'''
108108
if not self._count.acquire(False, None):
109109
raise Empty
110110
return self._queue.popleft()
111111

112-
def empty(self):
112+
def empty(self) -> bool:
113113
'''Return True if the queue is empty, False otherwise (not reliable!).'''
114114
return len(self._queue) == 0
115115

116-
def qsize(self):
116+
def qsize(self) -> int:
117117
'''Return the approximate size of the queue (not reliable!).'''
118118
return len(self._queue)

tests/core/test_listener.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def test_setup_and_teardown(self, mock_socket: mock.Mock) -> None:
3737
self.assertEqual(sock.setsockopt.call_count, 2)
3838
self.assertEqual(
3939
sock.setsockopt.call_args_list[0][0],
40-
(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1,),
40+
(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1),
4141
)
4242
self.assertEqual(
4343
sock.setsockopt.call_args_list[1][0],
44-
(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1,),
44+
(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),
4545
)
4646
sock.bind.assert_called_with(
4747
(str(flags.hostname), 0),
@@ -77,11 +77,11 @@ def test_unix_path_listener(self, mock_socket: mock.Mock, mock_remove: mock.Mock
7777
self.assertEqual(sock.setsockopt.call_count, 2)
7878
self.assertEqual(
7979
sock.setsockopt.call_args_list[0][0],
80-
(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1,),
80+
(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1),
8181
)
8282
self.assertEqual(
8383
sock.setsockopt.call_args_list[1][0],
84-
(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1,),
84+
(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),
8585
)
8686
sock.bind.assert_called_with(sock_path)
8787
sock.listen.assert_called_with(flags.backlog)

0 commit comments

Comments
 (0)