MCPcopy
hub / github.com/pydantic/pydantic / _build_url

Method _build_url

pydantic/v1/networks.py:289–308  ·  view source on GitHub ↗

Validate hosts and build the AnyUrl object. Split from `validate` so this method can be altered in `MultiHostDsn`.

(cls, m: Match[str], url: str, parts: 'Parts')

Source from the content-addressed store, hash-verified

287
288 @classmethod
289 def _build_url(cls, m: Match[str], url: str, parts: 'Parts') -> 'AnyUrl':
290 """
291 Validate hosts and build the AnyUrl object. Split from `validate` so this method
292 can be altered in `MultiHostDsn`.
293 """
294 host, tld, host_type, rebuild = cls.validate_host(parts)
295
296 return cls(
297 None if rebuild else url,
298 scheme=parts['scheme'],
299 user=parts['user'],
300 password=parts['password'],
301 host=host,
302 tld=tld,
303 host_type=host_type,
304 port=parts['port'],
305 path=parts['path'],
306 query=parts['query'],
307 fragment=parts['fragment'],
308 )
309
310 @staticmethod
311 def _match_url(url: str) -> Optional[Match[str]]:

Callers 1

validateMethod · 0.45

Calls 1

validate_hostMethod · 0.80

Tested by

no test coverage detected