def METHOD_NAME(cls, scope: Scope) -> URL:
    """Construct a URL from a :class:`Scope <.types.Scope>`
    Args:
        scope: A scope
    Returns:
        A URL
    """
    scheme = scope.get("scheme", "http")
    server = scope.get("server")
    path = scope.get("root_path", "") + scope["path"]
    query_string = scope.get("query_string", b"")
    # we use iteration here because it's faster, and headers might not yet be cached
    host = next(
        (
            header_value.decode("latin-1")
            for header_name, header_value in scope.get("headers", [])
            if header_name == b"host"
        ),
        "",
    )
    if server and not host:
        host, port = server
        default_port = _DEFAULT_SCHEME_PORTS[scheme]
        if port != default_port:
            host = f"{host}:{port}"
    return cls.from_components(
        scheme=scheme if server else "",
        query=query_string.decode(),
        netloc=host,
        path=path,
    )