diff options
author | hodbn <hodbn@users.noreply.github.com> | 2020-08-26 10:28:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-26 12:28:42 -0500 |
commit | d455be9463b547b4a6efb3b6de52abfe2b62e3e8 (patch) | |
tree | d180d290bdf1b8985b4ecd7c4701311b21dd8851 | |
parent | df1f6489a8c403cc085d07c2ed3d61d6b6a0a624 (diff) | |
download | urllib3-d455be9463b547b4a6efb3b6de52abfe2b62e3e8.tar.gz |
Blacken using black==20.8b1
-rw-r--r-- | dummyserver/handlers.py | 2 | ||||
-rw-r--r-- | dummyserver/testcase.py | 2 | ||||
-rw-r--r-- | src/urllib3/_collections.py | 2 | ||||
-rw-r--r-- | src/urllib3/connection.py | 2 | ||||
-rw-r--r-- | src/urllib3/contrib/_securetransport/low_level.py | 4 | ||||
-rw-r--r-- | src/urllib3/exceptions.py | 2 | ||||
-rw-r--r-- | src/urllib3/util/retry.py | 16 | ||||
-rw-r--r-- | src/urllib3/util/timeout.py | 16 | ||||
-rw-r--r-- | src/urllib3/util/wait.py | 4 | ||||
-rw-r--r-- | test/test_util.py | 4 | ||||
-rw-r--r-- | test/with_dummyserver/test_https.py | 7 | ||||
-rw-r--r-- | test/with_dummyserver/test_proxy_poolmanager.py | 5 |
12 files changed, 37 insertions, 29 deletions
diff --git a/dummyserver/handlers.py b/dummyserver/handlers.py index f199dee3..0a37fc55 100644 --- a/dummyserver/handlers.py +++ b/dummyserver/handlers.py @@ -266,7 +266,7 @@ class TestingApp(RequestHandler): return Response(json.dumps(dict(request.headers))) def successful_retry(self, request): - """ Handler which will return an error and then success + """Handler which will return an error and then success It's not currently very flexible as the number of retries is hard-coded. """ diff --git a/dummyserver/testcase.py b/dummyserver/testcase.py index 4e3cf593..a55a8c18 100644 --- a/dummyserver/testcase.py +++ b/dummyserver/testcase.py @@ -106,7 +106,7 @@ class IPV4SocketDummyServerTestCase(SocketDummyServerTestCase): class HTTPDummyServerTestCase(object): - """ A simple HTTP server that runs when your test class runs + """A simple HTTP server that runs when your test class runs Have your test class inherit from this one, and then a simple server will start when your tests run, and automatically shut down when they diff --git a/src/urllib3/_collections.py b/src/urllib3/_collections.py index 019d1511..2bae9047 100644 --- a/src/urllib3/_collections.py +++ b/src/urllib3/_collections.py @@ -190,7 +190,7 @@ class HTTPHeaderDict(MutableMapping): def pop(self, key, default=__marker): """D.pop(k[,d]) -> v, remove specified key and return the corresponding value. - If key is not found, d is returned if given, otherwise KeyError is raised. + If key is not found, d is returned if given, otherwise KeyError is raised. """ # Using the MutableMapping function directly fails due to the private marker. # Using ordinary dict.pop would expose the internal structures. diff --git a/src/urllib3/connection.py b/src/urllib3/connection.py index 8c63f1fa..8f3e4dd9 100644 --- a/src/urllib3/connection.py +++ b/src/urllib3/connection.py @@ -144,7 +144,7 @@ class HTTPConnection(_HTTPConnection, object): self._dns_host = value def _new_conn(self): - """ Establish a socket connection and set nodelay settings on it. + """Establish a socket connection and set nodelay settings on it. :return: New socket connection. """ diff --git a/src/urllib3/contrib/_securetransport/low_level.py b/src/urllib3/contrib/_securetransport/low_level.py index d3222e39..3d466a52 100644 --- a/src/urllib3/contrib/_securetransport/low_level.py +++ b/src/urllib3/contrib/_securetransport/low_level.py @@ -63,7 +63,9 @@ def _cfstr(py_bstr): """ c_str = ctypes.c_char_p(py_bstr) cf_str = CoreFoundation.CFStringCreateWithCString( - CoreFoundation.kCFAllocatorDefault, c_str, CFConst.kCFStringEncodingUTF8, + CoreFoundation.kCFAllocatorDefault, + c_str, + CFConst.kCFStringEncodingUTF8, ) return cf_str diff --git a/src/urllib3/exceptions.py b/src/urllib3/exceptions.py index e59ebbf2..1b6e13ca 100644 --- a/src/urllib3/exceptions.py +++ b/src/urllib3/exceptions.py @@ -102,7 +102,7 @@ class TimeoutStateError(HTTPError): class TimeoutError(HTTPError): - """ Raised when a socket timeout error occurs. + """Raised when a socket timeout error occurs. Catching this error will catch both :exc:`ReadTimeoutErrors <ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`. diff --git a/src/urllib3/util/retry.py b/src/urllib3/util/retry.py index 3b84a65c..d5df6af3 100644 --- a/src/urllib3/util/retry.py +++ b/src/urllib3/util/retry.py @@ -28,7 +28,7 @@ RequestHistory = namedtuple( class Retry(object): - """ Retry configuration. + """Retry configuration. Each retry attempt will create a new Retry object with updated values, so they can be safely reused. @@ -245,7 +245,7 @@ class Retry(object): return new_retries def get_backoff_time(self): - """ Formula for computing the current backoff + """Formula for computing the current backoff :rtype: float """ @@ -302,7 +302,7 @@ class Retry(object): time.sleep(backoff) def sleep(self, response=None): - """ Sleep between retry attempts. + """Sleep between retry attempts. This method will respect a server's ``Retry-After`` response header and sleep the duration of the time requested. If that is not present, it @@ -318,7 +318,7 @@ class Retry(object): self._sleep_backoff() def _is_connection_error(self, err): - """ Errors when we're fairly sure that the server did not receive the + """Errors when we're fairly sure that the server did not receive the request, so it should be safe to retry. """ if isinstance(err, ProxyError): @@ -326,13 +326,13 @@ class Retry(object): return isinstance(err, ConnectTimeoutError) def _is_read_error(self, err): - """ Errors that occur after the request has been started, so we should + """Errors that occur after the request has been started, so we should assume that the server began processing it. """ return isinstance(err, (ReadTimeoutError, ProtocolError)) def _is_method_retryable(self, method): - """ Checks if a given HTTP method should be retried upon, depending if + """Checks if a given HTTP method should be retried upon, depending if it is included on the method whitelist. """ if self.method_whitelist and method.upper() not in self.method_whitelist: @@ -341,7 +341,7 @@ class Retry(object): return True def is_retry(self, method, status_code, has_retry_after=False): - """ Is this method/status code retryable? (Based on whitelists and control + """Is this method/status code retryable? (Based on whitelists and control variables such as the number of total retries to allow, whether to respect the Retry-After header, whether this header is present, and whether the returned status code is on the list of status codes to @@ -385,7 +385,7 @@ class Retry(object): _pool=None, _stacktrace=None, ): - """ Return a new Retry object with incremented retry counters. + """Return a new Retry object with incremented retry counters. :param response: A response object, or None, if the server did not return a response. diff --git a/src/urllib3/util/timeout.py b/src/urllib3/util/timeout.py index b61fea75..d7201f84 100644 --- a/src/urllib3/util/timeout.py +++ b/src/urllib3/util/timeout.py @@ -17,7 +17,7 @@ current_time = getattr(time, "monotonic", time.time) class Timeout(object): - """ Timeout configuration. + """Timeout configuration. Timeouts can be defined as a default for a pool:: @@ -111,7 +111,7 @@ class Timeout(object): @classmethod def _validate_timeout(cls, value, name): - """ Check that a timeout attribute is valid. + """Check that a timeout attribute is valid. :param value: The timeout value to validate :param name: The name of the timeout attribute to validate. This is @@ -157,7 +157,7 @@ class Timeout(object): @classmethod def from_float(cls, timeout): - """ Create a new Timeout from a legacy timeout value. + """Create a new Timeout from a legacy timeout value. The timeout value used by httplib.py sets the same timeout on the connect(), and recv() socket requests. This creates a :class:`Timeout` @@ -172,7 +172,7 @@ class Timeout(object): return Timeout(read=timeout, connect=timeout) def clone(self): - """ Create a copy of the timeout object + """Create a copy of the timeout object Timeout properties are stored per-pool but each request needs a fresh Timeout object to ensure each one has its own start/stop configured. @@ -186,7 +186,7 @@ class Timeout(object): return Timeout(connect=self._connect, read=self._read, total=self.total) def start_connect(self): - """ Start the timeout clock, used during a connect() attempt + """Start the timeout clock, used during a connect() attempt :raises urllib3.exceptions.TimeoutStateError: if you attempt to start a timer that has been started already. @@ -197,7 +197,7 @@ class Timeout(object): return self._start_connect def get_connect_duration(self): - """ Gets the time elapsed since the call to :meth:`start_connect`. + """Gets the time elapsed since the call to :meth:`start_connect`. :return: Elapsed time in seconds. :rtype: float @@ -212,7 +212,7 @@ class Timeout(object): @property def connect_timeout(self): - """ Get the value to use when setting a connection timeout. + """Get the value to use when setting a connection timeout. This will be a positive float or integer, the value None (never timeout), or the default system timeout. @@ -230,7 +230,7 @@ class Timeout(object): @property def read_timeout(self): - """ Get the value for the read timeout. + """Get the value for the read timeout. This assumes some time has elapsed in the connection timeout and computes the read timeout appropriately. diff --git a/src/urllib3/util/wait.py b/src/urllib3/util/wait.py index d71d2fd7..53d10ee7 100644 --- a/src/urllib3/util/wait.py +++ b/src/urllib3/util/wait.py @@ -140,14 +140,14 @@ def wait_for_socket(*args, **kwargs): def wait_for_read(sock, timeout=None): - """ Waits for reading to be available on a given socket. + """Waits for reading to be available on a given socket. Returns True if the socket is readable, or False if the timeout expired. """ return wait_for_socket(sock, read=True, timeout=timeout) def wait_for_write(sock, timeout=None): - """ Waits for writing to be available on a given socket. + """Waits for writing to be available on a given socket. Returns True if the socket is readable, or False if the timeout expired. """ return wait_for_socket(sock, write=True, timeout=timeout) diff --git a/test/test_util.py b/test/test_util.py index 1630ece7..c41197ae 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -827,7 +827,9 @@ class TestUtilSSL(object): mock_context = Mock() with patch("warnings.warn") as warn: ssl_wrap_socket( - ssl_context=mock_context, sock=sock, server_hostname=server_hostname, + ssl_context=mock_context, + sock=sock, + server_hostname=server_hostname, ) return mock_context, warn diff --git a/test/with_dummyserver/test_https.py b/test/with_dummyserver/test_https.py index 95aef3eb..5eb241de 100644 --- a/test/with_dummyserver/test_https.py +++ b/test/with_dummyserver/test_https.py @@ -713,9 +713,10 @@ class TestHTTPS(HTTPSDummyServerTestCase): assert keylog_file.check(file=1), "keylogfile '%s' should exist" % str( keylog_file ) - assert keylog_file.read().startswith("# TLS secrets log file"), ( - "keylogfile '%s' should start with '# TLS secrets log file'" - % str(keylog_file) + assert keylog_file.read().startswith( + "# TLS secrets log file" + ), "keylogfile '%s' should start with '# TLS secrets log file'" % str( + keylog_file ) def test_alpn_default(self): diff --git a/test/with_dummyserver/test_proxy_poolmanager.py b/test/with_dummyserver/test_proxy_poolmanager.py index feface09..2125f144 100644 --- a/test/with_dummyserver/test_proxy_poolmanager.py +++ b/test/with_dummyserver/test_proxy_poolmanager.py @@ -38,7 +38,10 @@ class TestHTTPProxyManager(HTTPDummyProxyTestCase): cls.https_url = "https://%s:%d" % (cls.https_host, cls.https_port) cls.https_url_alt = "https://%s:%d" % (cls.https_host_alt, cls.https_port) cls.proxy_url = "http://%s:%d" % (cls.proxy_host, cls.proxy_port) - cls.https_proxy_url = "https://%s:%d" % (cls.proxy_host, cls.https_proxy_port,) + cls.https_proxy_url = "https://%s:%d" % ( + cls.proxy_host, + cls.https_proxy_port, + ) # Generate another CA to test verification failure cls.certs_dir = tempfile.mkdtemp() |