[go: nahoru, domu]

Skip to content

Commit

Permalink
Apply latest Black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson committed May 21, 2021
1 parent 1884878 commit f271c9c
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 56 deletions.
12 changes: 6 additions & 6 deletions dummyserver/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,27 @@ class TestingApp(RequestHandler):
"""

def get(self):
""" Handle GET requests """
"""Handle GET requests"""
self._call_method()

def post(self):
""" Handle POST requests """
"""Handle POST requests"""
self._call_method()

def put(self):
""" Handle PUT requests """
"""Handle PUT requests"""
self._call_method()

def options(self):
""" Handle OPTIONS requests """
"""Handle OPTIONS requests"""
self._call_method()

def head(self):
""" Handle HEAD requests """
"""Handle HEAD requests"""
self._call_method()

def _call_method(self):
""" Call the correct method in this class based on the incoming URI """
"""Call the correct method in this class based on the incoming URI"""
req = self.request
req.params = {}
for k, v in req.arguments.items():
Expand Down
4 changes: 2 additions & 2 deletions dummyserver/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@


def _resolves_to_ipv6(host):
""" Returns True if the system resolves host to an IPv6 address by default. """
"""Returns True if the system resolves host to an IPv6 address by default."""
resolves_to_ipv6 = False
try:
for res in socket.getaddrinfo(host, None, socket.AF_UNSPEC):
Expand All @@ -54,7 +54,7 @@ def _resolves_to_ipv6(host):


def _has_ipv6(host):
""" Returns True if the system can bind an IPv6 address. """
"""Returns True if the system can bind an IPv6 address."""
sock = None
has_ipv6 = False

Expand Down
4 changes: 2 additions & 2 deletions src/urllib3/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def connect(self):
self._prepare_conn(conn)

def putrequest(self, method, url, *args, **kwargs):
""""""
""" """
# Empty docstring because the indentation of CPython's implementation
# is broken but we don't want this method in our documentation.
match = _CONTAINS_CONTROL_CHAR_RE.search(method)
Expand All @@ -214,7 +214,7 @@ def putrequest(self, method, url, *args, **kwargs):
return _HTTPConnection.putrequest(self, method, url, *args, **kwargs)

def putheader(self, header, *values):
""""""
""" """
if not any(isinstance(v, str) and v == SKIP_HEADER for v in values):
_HTTPConnection.putheader(self, header, *values)
elif six.ensure_str(header.lower()) not in SKIPPABLE_HEADERS:
Expand Down
2 changes: 1 addition & 1 deletion src/urllib3/connectionpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def _prepare_proxy(self, conn):
pass

def _get_timeout(self, timeout):
""" Helper that always returns a :class:`urllib3.util.Timeout` """
"""Helper that always returns a :class:`urllib3.util.Timeout`"""
if timeout is _Default:
return self.timeout.clone()

Expand Down
2 changes: 1 addition & 1 deletion src/urllib3/util/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def allowed_gai_family():


def _has_ipv6(host):
""" Returns True if the system can bind an IPv6 address. """
"""Returns True if the system can bind an IPv6 address."""
sock = None
has_ipv6 = False

Expand Down
6 changes: 3 additions & 3 deletions src/urllib3/util/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def new(self, **kw):

@classmethod
def from_int(cls, retries, redirect=True, default=None):
""" Backwards-compatibility for the old retries format."""
"""Backwards-compatibility for the old retries format."""
if retries is None:
retries = default if default is not None else cls.DEFAULT

Expand Down Expand Up @@ -374,7 +374,7 @@ def parse_retry_after(self, retry_after):
return seconds

def get_retry_after(self, response):
""" Get the value of Retry-After in seconds. """
"""Get the value of Retry-After in seconds."""

retry_after = response.getheader("Retry-After")

Expand Down Expand Up @@ -468,7 +468,7 @@ def is_retry(self, method, status_code, has_retry_after=False):
)

def is_exhausted(self):
""" Are we out of retries? """
"""Are we out of retries?"""
retry_counts = (
self.total,
self.connect,
Expand Down
2 changes: 1 addition & 1 deletion src/urllib3/util/ssltransport.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _wrap_ssl_read(self, len, buffer=None):
raise

def _ssl_io_loop(self, func, *args):
""" Performs an I/O loop between incoming/outgoing and the socket."""
"""Performs an I/O loop between incoming/outgoing and the socket."""
should_loop = True
ret = None

Expand Down
4 changes: 2 additions & 2 deletions test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@


def _can_resolve(host):
""" Returns True if the system can resolve host to an address. """
"""Returns True if the system can resolve host to an address."""
try:
socket.getaddrinfo(host, None, socket.AF_UNSPEC)
return True
Expand All @@ -63,7 +63,7 @@ def _can_resolve(host):


def has_alpn(ctx_cls=None):
""" Detect if ALPN support is enabled. """
"""Detect if ALPN support is enabled."""
ctx_cls = ctx_cls or util.SSLContext
ctx = ctx_cls(protocol=ssl_.PROTOCOL_TLS)
try:
Expand Down
2 changes: 1 addition & 1 deletion test/appengine/test_gae_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def setup_method(self, method):
self.pool = MockPool(self.host, self.port, self.manager)

def test_default_method_whitelist_retried(self):
""" urllib3 should retry methods in the default method whitelist """
"""urllib3 should retry methods in the default method whitelist"""
retry = urllib3.util.retry.Retry(total=1, status_forcelist=[418])
# Use HEAD instead of OPTIONS, as URLFetch doesn't support OPTIONS
resp = self.pool.request(
Expand Down
16 changes: 8 additions & 8 deletions test/test_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def no_retry_deprecations():

class TestRetry(object):
def test_string(self):
""" Retry string representation looks the way we expect """
"""Retry string representation looks the way we expect"""
retry = Retry()
assert (
str(retry)
Expand All @@ -50,7 +50,7 @@ def test_retry_both_specified(self):
assert e.value.reason == error

def test_retry_higher_total_loses(self):
""" A lower connect timeout than the total is honored """
"""A lower connect timeout than the total is honored"""
error = ConnectTimeoutError()
retry = Retry(connect=2, total=3)
retry = retry.increment(error=error)
Expand All @@ -59,7 +59,7 @@ def test_retry_higher_total_loses(self):
retry.increment(error=error)

def test_retry_higher_total_loses_vs_read(self):
""" A lower read timeout than the total is honored """
"""A lower read timeout than the total is honored"""
error = ReadTimeoutError(None, "/", "read timed out")
retry = Retry(read=2, total=3)
retry = retry.increment(method="GET", error=error)
Expand All @@ -68,7 +68,7 @@ def test_retry_higher_total_loses_vs_read(self):
retry.increment(method="GET", error=error)

def test_retry_total_none(self):
""" if Total is none, connect error should take precedence """
"""if Total is none, connect error should take precedence"""
error = ConnectTimeoutError()
retry = Retry(connect=2, total=None)
retry = retry.increment(error=error)
Expand All @@ -85,7 +85,7 @@ def test_retry_total_none(self):
assert not retry.is_exhausted()

def test_retry_default(self):
""" If no value is specified, should retry connects 3 times """
"""If no value is specified, should retry connects 3 times"""
retry = Retry()
assert retry.total == 10
assert retry.connect is None
Expand All @@ -107,7 +107,7 @@ def test_retry_default(self):
assert not Retry(False).raise_on_redirect

def test_retry_other(self):
""" If an unexpected error is raised, should retry other times """
"""If an unexpected error is raised, should retry other times"""
other_error = SSLError()
retry = Retry(connect=1)
retry = retry.increment(error=other_error)
Expand All @@ -121,7 +121,7 @@ def test_retry_other(self):
assert e.value.reason == other_error

def test_retry_read_zero(self):
""" No second chances on read timeouts, by default """
"""No second chances on read timeouts, by default"""
error = ReadTimeoutError(None, "/", "read timed out")
retry = Retry(read=0)
with pytest.raises(MaxRetryError) as e:
Expand All @@ -140,7 +140,7 @@ def test_status_counter(self):
)

def test_backoff(self):
""" Backoff is computed correctly """
"""Backoff is computed correctly"""
max_backoff = Retry.BACKOFF_MAX

retry = Retry(total=100, backoff_factor=0.2)
Expand Down
16 changes: 8 additions & 8 deletions test/test_retry_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def expect_retry_deprecation():

class TestRetry(object):
def test_string(self):
""" Retry string representation looks the way we expect """
"""Retry string representation looks the way we expect"""
retry = Retry()
assert (
str(retry)
Expand All @@ -52,7 +52,7 @@ def test_retry_both_specified(self):
assert e.value.reason == error

def test_retry_higher_total_loses(self):
""" A lower connect timeout than the total is honored """
"""A lower connect timeout than the total is honored"""
error = ConnectTimeoutError()
retry = Retry(connect=2, total=3)
retry = retry.increment(error=error)
Expand All @@ -61,7 +61,7 @@ def test_retry_higher_total_loses(self):
retry.increment(error=error)

def test_retry_higher_total_loses_vs_read(self):
""" A lower read timeout than the total is honored """
"""A lower read timeout than the total is honored"""
error = ReadTimeoutError(None, "/", "read timed out")
retry = Retry(read=2, total=3)
retry = retry.increment(method="GET", error=error)
Expand All @@ -70,7 +70,7 @@ def test_retry_higher_total_loses_vs_read(self):
retry.increment(method="GET", error=error)

def test_retry_total_none(self):
""" if Total is none, connect error should take precedence """
"""if Total is none, connect error should take precedence"""
error = ConnectTimeoutError()
retry = Retry(connect=2, total=None)
retry = retry.increment(error=error)
Expand All @@ -87,7 +87,7 @@ def test_retry_total_none(self):
assert not retry.is_exhausted()

def test_retry_default(self):
""" If no value is specified, should retry connects 3 times """
"""If no value is specified, should retry connects 3 times"""
retry = Retry()
assert retry.total == 10
assert retry.connect is None
Expand All @@ -109,7 +109,7 @@ def test_retry_default(self):
assert not Retry(False).raise_on_redirect

def test_retry_other(self):
""" If an unexpected error is raised, should retry other times """
"""If an unexpected error is raised, should retry other times"""
other_error = SSLError()
retry = Retry(connect=1)
retry = retry.increment(error=other_error)
Expand All @@ -123,7 +123,7 @@ def test_retry_other(self):
assert e.value.reason == other_error

def test_retry_read_zero(self):
""" No second chances on read timeouts, by default """
"""No second chances on read timeouts, by default"""
error = ReadTimeoutError(None, "/", "read timed out")
retry = Retry(read=0)
with pytest.raises(MaxRetryError) as e:
Expand All @@ -142,7 +142,7 @@ def test_status_counter(self):
)

def test_backoff(self):
""" Backoff is computed correctly """
"""Backoff is computed correctly"""
max_backoff = Retry.BACKOFF_MAX

retry = Retry(total=100, backoff_factor=0.2)
Expand Down
10 changes: 5 additions & 5 deletions test/test_ssltransport.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def socket_handler(listener):

@pytest.mark.timeout(PER_TEST_TIMEOUT)
def test_start_closed_socket(self):
""" Errors generated from an unconnected socket should bubble up."""
"""Errors generated from an unconnected socket should bubble up."""
sock = socket.socket(socket.AF_INET)
context = ssl.create_default_context()
sock.close()
Expand All @@ -110,7 +110,7 @@ def test_start_closed_socket(self):

@pytest.mark.timeout(PER_TEST_TIMEOUT)
def test_close_after_handshake(self):
""" Socket errors should be bubbled up """
"""Socket errors should be bubbled up"""
self.start_dummy_server()

sock = socket.create_connection((self.host, self.port))
Expand All @@ -123,7 +123,7 @@ def test_close_after_handshake(self):

@pytest.mark.timeout(PER_TEST_TIMEOUT)
def test_wrap_existing_socket(self):
""" Validates a single TLS layer can be established. """
"""Validates a single TLS layer can be established."""
self.start_dummy_server()

sock = socket.create_connection((self.host, self.port))
Expand Down Expand Up @@ -187,7 +187,7 @@ def shutdown_handler(listener):

@pytest.mark.timeout(PER_TEST_TIMEOUT)
def test_ssl_object_attributes(self):
""" Ensures common ssl attributes are exposed """
"""Ensures common ssl attributes are exposed"""
self.start_dummy_server()

sock = socket.create_connection((self.host, self.port))
Expand Down Expand Up @@ -215,7 +215,7 @@ def test_ssl_object_attributes(self):

@pytest.mark.timeout(PER_TEST_TIMEOUT)
def test_socket_object_attributes(self):
""" Ensures common socket attributes are exposed """
"""Ensures common socket attributes are exposed"""
self.start_dummy_server()

sock = socket.create_connection((self.host, self.port))
Expand Down
2 changes: 1 addition & 1 deletion test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def test_disable_warnings(self):
assert len(w) == 1

def _make_time_pass(self, seconds, timeout, time_mock):
""" Make some time pass for the timeout object """
"""Make some time pass for the timeout object"""
time_mock.return_value = TIMEOUT_EPOCH
timeout.start_connect()
time_mock.return_value = TIMEOUT_EPOCH + seconds
Expand Down
Loading

0 comments on commit f271c9c

Please sign in to comment.