Skip to content

Commit 076ffde

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a9beaf1 commit 076ffde

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

proxy/core/connection/connection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
logger = logging.getLogger(__name__)
2222

23-
EMPTY_MV = memoryview(b"")
23+
EMPTY_MV = memoryview(b'')
2424

2525
class TcpConnectionUninitializedException(Exception):
2626
pass
@@ -79,7 +79,7 @@ def recv(
7979
self._recv_leakage.putback(buffer_size - size)
8080
if size == 0:
8181
return None
82-
logger.debug("received %d bytes from %s" % (size, self.tag))
82+
logger.debug('received %d bytes from %s' % (size, self.tag))
8383
logger.info(data)
8484
return memoryview(data)
8585

@@ -121,7 +121,7 @@ def flush(self, max_send_size: Optional[int] = None) -> int:
121121
self._flush_leakage.putback(allowed_bytes - sent)
122122
except BlockingIOError:
123123
logger.warning(
124-
"BlockingIOError when trying send to {0}".format(self.tag)
124+
'BlockingIOError when trying send to {0}'.format(self.tag),
125125
)
126126
del mv
127127
return 0
@@ -133,7 +133,7 @@ def flush(self, max_send_size: Optional[int] = None) -> int:
133133
else:
134134
self.buffer[0] = mv[sent:]
135135
# if sent > 0:
136-
logger.debug("flushed %d bytes to %s" % (sent, self.tag))
136+
logger.debug('flushed %d bytes to %s' % (sent, self.tag))
137137
logger.info(mv[:sent].tobytes())
138138
del mv
139139
return sent

proxy/core/work/fd/fd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ def work(self, *args: Any) -> None:
4141
publisher_id=self.__class__.__qualname__,
4242
)
4343
try:
44-
logger.debug("Initializing work#{0}".format(fileno))
44+
logger.debug('Initializing work#{0}'.format(fileno))
4545
self.works[fileno].initialize()
4646
self._total += 1
4747
except Exception as e:
4848
logger.exception( # pragma: no cover
4949
'Exception occurred during initialization',
5050
exc_info=e,
5151
)
52-
self._cleanup(fileno, "error")
52+
self._cleanup(fileno, 'error')
5353

5454
@property
5555
@abstractmethod

proxy/core/work/threadless.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,15 @@ def _cleanup_inactive(self) -> None:
301301
if self.works[work_id].is_inactive():
302302
inactive_works.append(work_id)
303303
for work_id in inactive_works:
304-
self._cleanup(work_id, "inactive")
304+
self._cleanup(work_id, 'inactive')
305305

306306
# TODO: HttpProtocolHandler.shutdown can call flush which may block
307307
def _cleanup(self, work_id: int, reason: str) -> None:
308308
if work_id in self.registered_events_by_work_ids:
309309
assert self.selector
310310
for fileno in self.registered_events_by_work_ids[work_id]:
311311
logger.debug(
312-
"fd#{0} unregistered by work#{1}, reason: {2}".format(
312+
'fd#{0} unregistered by work#{1}, reason: {2}'.format(
313313
fileno,
314314
work_id,
315315
reason,
@@ -376,7 +376,7 @@ async def _run_once(self) -> bool:
376376
teardown = True
377377
finally:
378378
if teardown:
379-
self._cleanup(work_id, "teardown")
379+
self._cleanup(work_id, 'teardown')
380380
# self.cleanup(int(task.get_name()))
381381
# logger.debug(
382382
# "Done executing works, {0} pending, {1} registered".format(

proxy/http/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def client(
3232
conn_close: bool = True,
3333
scheme: bytes = HTTPS_PROTO,
3434
timeout: float = DEFAULT_TIMEOUT,
35-
content_type: bytes = b"application/x-www-form-urlencoded",
35+
content_type: bytes = b'application/x-www-form-urlencoded',
3636
verify: bool = False,
3737
) -> Optional[HttpParser]:
3838
"""HTTP Client"""

proxy/http/server/reverse.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def handle_request(self, request: HttpParser) -> None:
8686
)
8787
needs_upstream = True
8888
logger.debug(
89-
"Starting connection to upstream {0}".format(self.choice)
89+
'Starting connection to upstream {0}'.format(self.choice),
9090
)
9191
break
9292
# Dynamic routes
@@ -99,21 +99,21 @@ def handle_request(self, request: HttpParser) -> None:
9999
needs_upstream = True
100100
self._upstream_proxy_pass = str(self.choice)
101101
logger.debug(
102-
"Starting connection to upstream {0}".format(choice)
102+
'Starting connection to upstream {0}'.format(choice),
103103
)
104104
elif isinstance(choice, memoryview):
105105
self.client.queue(choice)
106106
self._upstream_proxy_pass = '{0} bytes'.format(len(choice))
107-
logger.debug("Sending raw response to client")
107+
logger.debug('Sending raw response to client')
108108
else:
109109
self.upstream = choice
110110
self._upstream_proxy_pass = '{0}:{1}'.format(
111111
*self.upstream.addr,
112112
)
113113
logger.debug(
114-
"Using existing connection to upstream {0}".format(
115-
self.upstream.addr
116-
)
114+
'Using existing connection to upstream {0}'.format(
115+
self.upstream.addr,
116+
),
117117
)
118118
break
119119
else:

tests/core/test_leakage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_initial_consume_no_tokens(self):
2121
rate = 100 # bytes per second
2222
bucket = Leakage(rate)
2323
self.assertEqual(
24-
bucket.consume(150), 100
24+
bucket.consume(150), 100,
2525
) # No tokens yet, so expect 0 bytes to be sent
2626

2727
def test_consume_with_refill(self):

tests/http/parser/test_http_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ def test_byte_by_byte(self) -> None:
918918
]
919919
response.parse(memoryview(request[0]))
920920
self.assertEqual(response.state, httpParserStates.RCVING_BODY)
921-
self.assertEqual(response.code, b"200")
921+
self.assertEqual(response.code, b'200')
922922
for byte in (bytes([b]) for b in request[1]):
923923
response.parse(memoryview(byte))
924924
self.assertEqual(response.state, httpParserStates.COMPLETE)

0 commit comments

Comments
 (0)