From 663f82cd5ffb5032f67c8b23428089f79fd2ff02 Mon Sep 17 00:00:00 2001 From: Ratan Kulshreshtha Date: Wed, 5 Jun 2019 00:01:58 +0530 Subject: [PATCH] Ignore flake8 errors that are introduced deliberately by black (#1631) --- setup.cfg | 1 + src/urllib3/connection.py | 6 +++--- src/urllib3/contrib/pyopenssl.py | 4 ++-- src/urllib3/contrib/securetransport.py | 4 +--- src/urllib3/util/url.py | 4 ++-- test/test_response.py | 8 ++++---- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/setup.cfg b/setup.cfg index dbd367b866..16d64d20a6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,4 +1,5 @@ [flake8] +ignore = E501, E203, W503, W504 exclude=./docs/conf.py,./src/urllib3/packages/* max-line-length=99 diff --git a/src/urllib3/connection.py b/src/urllib3/connection.py index f0396f2550..27bc186796 100644 --- a/src/urllib3/connection.py +++ b/src/urllib3/connection.py @@ -412,9 +412,9 @@ def connect(self): if not cert.get("subjectAltName", ()): warnings.warn( ( - "Certificate for {0} has no `subjectAltName`, falling back to check for a " # noqa - "`commonName` for now. This feature is being removed by major browsers and " # noqa - "deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 " # noqa + "Certificate for {0} has no `subjectAltName`, falling back to check for a " + "`commonName` for now. This feature is being removed by major browsers and " + "deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 " "for details.)".format(hostname) ), SubjectAltNameWarning, diff --git a/src/urllib3/contrib/pyopenssl.py b/src/urllib3/contrib/pyopenssl.py index 58ea971e9f..3051ef3af2 100644 --- a/src/urllib3/contrib/pyopenssl.py +++ b/src/urllib3/contrib/pyopenssl.py @@ -187,7 +187,7 @@ def idna_encode(name): try: for prefix in [u"*.", u"."]: if name.startswith(prefix): - name = name[len(prefix) :] # noqa + name = name[len(prefix) :] return prefix.encode("ascii") + idna.encode(name) return idna.encode(name) except idna.core.IDNAError: @@ -349,7 +349,7 @@ def sendall(self, data): total_sent = 0 while total_sent < len(data): sent = self._send_until_done( - data[total_sent : total_sent + SSL_WRITE_BLOCKSIZE] # noqa + data[total_sent : total_sent + SSL_WRITE_BLOCKSIZE] ) total_sent += sent diff --git a/src/urllib3/contrib/securetransport.py b/src/urllib3/contrib/securetransport.py index 7b975c0da4..24e6b5c4d9 100644 --- a/src/urllib3/contrib/securetransport.py +++ b/src/urllib3/contrib/securetransport.py @@ -616,9 +616,7 @@ def send(self, data): def sendall(self, data): total_sent = 0 while total_sent < len(data): - sent = self.send( - data[total_sent : total_sent + SSL_WRITE_BLOCKSIZE] # noqa - ) + sent = self.send(data[total_sent : total_sent + SSL_WRITE_BLOCKSIZE]) total_sent += sent def shutdown(self): diff --git a/src/urllib3/util/url.py b/src/urllib3/util/url.py index 2ba45360d9..f225cd8bf0 100644 --- a/src/urllib3/util/url.py +++ b/src/urllib3/util/url.py @@ -149,7 +149,7 @@ def split_first(s, delims): if min_idx is None or min_idx < 0: return s, "", None - return s[:min_idx], s[min_idx + 1 :], min_delim # noqa + return s[:min_idx], s[min_idx + 1 :], min_delim def _encode_invalid_chars(component, allowed_chars, encoding="utf-8"): @@ -173,7 +173,7 @@ def _encode_invalid_chars(component, allowed_chars, encoding="utf-8"): for i in range(0, len(uri_bytes)): # Will return a single character bytestring on both Python 2 & 3 - byte = uri_bytes[i : i + 1] # noqa + byte = uri_bytes[i : i + 1] byte_ord = ord(byte) if (is_percent_encoded and byte == b"%") or ( byte_ord < 128 and byte.decode() in allowed_chars diff --git a/test/test_response.py b/test/test_response.py index 18b3e37379..23a63be1d0 100644 --- a/test/test_response.py +++ b/test/test_response.py @@ -440,7 +440,7 @@ class MockCompressedDataReading(BytesIO): def __init__(self, payload, payload_part_size): self.payloads = [ - payload[i * payload_part_size : (i + 1) * payload_part_size] # noqa + payload[i * payload_part_size : (i + 1) * payload_part_size] for i in range(NUMBER_OF_READS + 1) ] @@ -633,7 +633,7 @@ def stream(): data = compress.compress(b"foobar") data += compress.flush() for i in range(0, len(data), 2): - yield data[i : i + 2] # noqa + yield data[i : i + 2] fp = MockChunkedEncodingResponse(list(stream())) r = httplib.HTTPResponse(MockSock) @@ -801,7 +801,7 @@ def stream(): data = compress.compress(b"foo\nbar") data += compress.flush() for i in range(0, len(data), 2): - yield data[i : i + 2] # noqa + yield data[i : i + 2] fp = MockChunkedEncodingResponse(list(stream())) r = httplib.HTTPResponse(MockSock) @@ -862,7 +862,7 @@ def pop_current_chunk(self, amt=-1, till_crlf=False): return b"" else: chunk_part = self.cur_chunk[: i + 2] - self.cur_chunk = self.cur_chunk[i + 2 :] # noqa + self.cur_chunk = self.cur_chunk[i + 2 :] return chunk_part elif amt <= -1: chunk_part = self.cur_chunk