human
I wrote the below code

    def _normalize_netloc(scheme, netloc):
        parts = netloc.split(u'@', 1)[(-1)].split(u':', 1)
        if (len(parts) == 2):
            (netloc, port) = parts
            if (((scheme == u'http') and (port == u'80')) or ((scheme == u'https') and (port == u'443'))):
                port = None
        else:
            netloc = parts[0]
            port = None
        if (port is not None):
            netloc += (u':' + port)
        return netloc
    path = uri_to_iri(path_or_url, charset, errors)
    if isinstance(environ_or_baseurl, dict):
        environ_or_baseurl = get_current_url(environ_or_baseurl, root_only=True)
    base_iri = uri_to_iri(environ_or_baseurl, charset, errors)
    (base_scheme, base_netloc, base_path) = url_parse(base_iri)[:3]
    (cur_scheme, cur_netloc, cur_path) = url_parse(url_join(base_iri, path))[:3]
    base_netloc = _normalize_netloc(base_scheme, base_netloc)
    cur_netloc = _normalize_netloc(cur_scheme, cur_netloc)
    if collapse_http_schemes:
        for scheme in (base_scheme, cur_scheme):
            if (scheme not in (u'http', u'https')):
                return None
    elif (not ((base_scheme in (u'http', u'https')) and (base_scheme == cur_scheme))):
        return None
    if (base_netloc != cur_netloc):
        return None
    base_path = base_path.rstrip(u'/')
    if (not cur_path.startswith(base_path)):
        return None
    return (u'/' + cur_path[len(base_path):].lstrip(u'/'))

What's a good function header?
 ... Here's a good function header?
assistant
#Here's a good function header.

def extract_path_info(environ_or_baseurl, path_or_url, charset='utf-8', errors='replace', collapse_http_schemes=True):