Change from str.format() to f-strings
MODIFY
src/urllib3/connection.py
src/urllib3/connection.py
@@ -255,10 +255,11 @@ class HTTPConnection(_HTTPConnection):
if not any(isinstance(v, str) and v == SKIP_HEADER for v in values):
super().putheader(header, *values)
elif to_str(header.lower()) not in SKIPPABLE_HEADERS:
- raise ValueError(
- "urllib3.util.SKIP_HEADER only supports '{}'".format(
- "', '".join(map(str.title, sorted(SKIPPABLE_HEADERS)))
+ skippable_headers = "', '".join(
+ [str.title(header) for header in sorted(SKIPPABLE_HEADERS)]
)
+ raise ValueError(
+ f"urllib3.util.SKIP_HEADER only supports '{skippable_headers}'"
)
# `request` method's signature intentionally violates LSP.

MODIFY
src/urllib3/contrib/_securetransport/bindings.py
src/urllib3/contrib/_securetransport/bindings.py
@@ -54,9 +54,7 @@ version = platform.mac_ver()[0]
version_info = tuple(map(int, version.split(".")))
if version_info < (10, 8):
raise OSError(
- "Only OS X 10.8 and newer are supported, not {}.{}".format(
- version_info[0], version_info[1]
- )
+ f"Only OS X 10.8 and newer are supported, not {version_info[0]}.{version_info[1]}"
)

MODIFY
test/test_util.py
test/test_util.py
@@ -200,7 +200,7 @@ class TestUtil:
def test_control_characters_are_percent_encoded(self, char):
percent_char = "%" + (hex(ord(char))[2:].zfill(2).upper())
url = parse_url(
- "http://user{0}@example.com/path{0}?query{0}#fragment{0}".format(char)
+ f"http://user{char}@example.com/path{char}?query{char}#fragment{char}"
)
assert url == Url(

Change from str.format() to f-strings