Skip to content

Commit 895bb1c

Browse files
committed
fix ruff linting errors
1 parent e87b0fd commit 895bb1c

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

httpx/_utils.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,15 @@ def __lt__(self, other: URLPattern) -> bool:
243243

244244
def __eq__(self, other: typing.Any) -> bool:
245245
return isinstance(other, WildcardURLPattern) and self.pattern == other.pattern
246-
246+
247247

248248
class IPNetPattern(Pattern):
249249
def __init__(self, ip_net: str) -> None:
250250
try:
251-
addr, range = ip_net.split('/', 1)
252-
if addr[0] == '[' and addr[-1] == ']':
251+
addr, range = ip_net.split("/", 1)
252+
if addr[0] == "[" and addr[-1] == "]":
253253
addr = addr[1:-1]
254-
ip_net = f'{addr}/{range}'
254+
ip_net = f"{addr}/{range}"
255255
except ValueError:
256256
pass # not a range
257257
self.net = ipaddress.ip_network(ip_net)
@@ -261,7 +261,7 @@ def matches(self, other: URL):
261261
return ipaddress.ip_address(other.host) in self.net
262262
except ValueError:
263263
return False
264-
264+
265265
@property
266266
def priority(self) -> tuple[int, int, int]:
267267
return -1, 0, 0 # higher priority than URLPatterns
@@ -274,17 +274,17 @@ def __lt__(self, other: URLPattern) -> bool:
274274

275275
def __eq__(self, other: typing.Any) -> bool:
276276
return isinstance(other, IPNetPattern) and self.net == other.net
277-
277+
278278

279279
URLPattern = IPNetPattern | WildcardURLPattern
280280

281281

282282
def build_url_pattern(pattern: str) -> URLPattern:
283283
try:
284-
proto, rest = pattern.split('://', 1)
285-
if proto == 'all' and '/' in rest:
286-
return IPNetPattern(rest)
287-
except ValueError: # covers .split() and IPNetPattern
284+
proto, rest = pattern.split("://", 1)
285+
if proto == "all" and "/" in rest:
286+
return IPNetPattern(rest)
287+
except ValueError: # covers .split() and IPNetPattern
288288
pass
289289
return WildcardURLPattern(pattern)
290290

@@ -302,4 +302,4 @@ def is_ipv6_hostname(hostname: str) -> bool:
302302
ipaddress.IPv6Address(hostname.split("/")[0])
303303
except Exception:
304304
return False
305-
return True
305+
return True

tests/test_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ def test_get_environment_proxies(environment, proxies):
128128
("http://", "https://example.com", False),
129129
("all://", "https://example.com:123", True),
130130
("", "https://example.com:123", True),
131-
('all://192.168.0.0/24', 'http://192.168.0.1', True),
132-
('all://192.168.0.0/24', 'https://192.168.1.1', False),
133-
('all://[2001:db8:abcd:0012::]/64', 'http://[2001:db8:abcd:12::1]', True),
134-
('all://[2001:db8:abcd:0012::]/64', 'http://[2001:db8:abcd:13::1]:8080', False),
131+
("all://192.168.0.0/24", "http://192.168.0.1", True),
132+
("all://192.168.0.0/24", "https://192.168.1.1", False),
133+
("all://[2001:db8:abcd:0012::]/64", "http://[2001:db8:abcd:12::1]", True),
134+
("all://[2001:db8:abcd:0012::]/64", "http://[2001:db8:abcd:13::1]:8080", False),
135135
],
136136
)
137137
def test_url_matches(pattern, url, expected):

0 commit comments

Comments
 (0)