Skip to content

Commit e6c88ad

Browse files
committed
pep8 fixes
1 parent b9df24b commit e6c88ad

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

aiohttp/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ def request(method, url, *,
127127
resp.close(force=True)
128128
break
129129

130-
# For 301 and 302, mimic IE behaviour, now changed in RFC. Details: https://github.com/kennethreitz/requests/pull/269
130+
# For 301 and 302, mimic IE behaviour, now changed in RFC.
131+
# Details: https://github.com/kennethreitz/requests/pull/269
131132
if resp.status != 307:
132133
method = 'GET'
133134
data = None

aiohttp/protocol.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,8 @@ def add_header(self, name, value):
579579
assert set(name).issubset(ASCIISET), \
580580
'Header name should contain ASCII chars, got {!r}'.format(name)
581581
assert isinstance(value, str), \
582-
'Header {!r} should have string value, got {!r}'.format(name, value)
582+
'Header {!r} should have string value, got {!r}'.format(
583+
name, value)
583584

584585
name = name.strip().upper()
585586
value = value.strip()

aiohttp/websocket.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
MSG_PONG = OPCODE_PONG = 0xa
2121

2222
WS_KEY = b'258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
23-
WS_HDRS = ('UPGRADE', 'CONNECTION',
24-
'SEC-WEBSOCKET-VERSION', 'SEC-WEBSOCKET-KEY', 'SEC-WEBSOCKET-PROTOCOL')
23+
WS_HDRS = ('UPGRADE',
24+
'CONNECTION',
25+
'SEC-WEBSOCKET-VERSION',
26+
'SEC-WEBSOCKET-KEY',
27+
'SEC-WEBSOCKET-PROTOCOL')
2528

2629
Message = collections.namedtuple('Message', ['tp', 'data', 'extra'])
2730

@@ -205,13 +208,13 @@ def do_handshake(method, headers, transport, protocols=()):
205208
raise errors.HttpBadRequest(
206209
'No CONNECTION upgrade hdr: {}'.format(
207210
headers.get('CONNECTION')))
208-
211+
209212
# find common sub-protocol between client and server
210213
protocol = None
211214
if 'SEC-WEBSOCKET-PROTOCOL' in headers:
212215
req_protocols = {str(proto.strip()) for proto in
213-
headers['SEC-WEBSOCKET-PROTOCOL'].split(',')}
214-
216+
headers['SEC-WEBSOCKET-PROTOCOL'].split(',')}
217+
215218
for proto in protocols:
216219
if proto in req_protocols:
217220
protocol = proto
@@ -237,12 +240,13 @@ def do_handshake(method, headers, transport, protocols=()):
237240
raise errors.HttpBadRequest(
238241
'Handshake error: {!r}'.format(key)) from None
239242

240-
response_headers = [('UPGRADE', 'websocket'),
241-
('CONNECTION', 'upgrade'),
242-
('TRANSFER-ENCODING', 'chunked'),
243-
('SEC-WEBSOCKET-ACCEPT', base64.b64encode(
244-
hashlib.sha1(key.encode() + WS_KEY).digest()).decode())]
245-
243+
response_headers = [
244+
('UPGRADE', 'websocket'),
245+
('CONNECTION', 'upgrade'),
246+
('TRANSFER-ENCODING', 'chunked'),
247+
('SEC-WEBSOCKET-ACCEPT', base64.b64encode(
248+
hashlib.sha1(key.encode() + WS_KEY).digest()).decode())]
249+
246250
if protocol:
247251
response_headers.append(('SEC-WEBSOCKET-PROTOCOL', protocol))
248252

tests/test_websocket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def test_handshake_protocol(self):
454454

455455
self.assertEqual(protocol, proto)
456456

457-
#also test if we reply with the protocol
457+
# also test if we reply with the protocol
458458
resp_headers = dict(resp_headers)
459459
self.assertEqual(resp_headers['SEC-WEBSOCKET-PROTOCOL'], proto)
460460

0 commit comments

Comments
 (0)