@@ -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
248248class 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
279279URLPattern = IPNetPattern | WildcardURLPattern
280280
281281
282282def 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
0 commit comments