Skip to content

Commit

Permalink
refactor: Use urllib.parse.urlsplit over urlparse (#1997)
Browse files Browse the repository at this point in the history
* Use urllib.parse.urlsplit over urllib.parse.urlparse to avoid having to deal with
  urlparse's 'params' argument which incurs a performance cost.
   - c.f. https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlsplit
   - c.f. https://youtu.be/ABJvdsIANds
  • Loading branch information
matthewfeickert authored Sep 9, 2022
1 parent 43c9ecc commit 8219a84
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pyhf/contrib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from io import BytesIO
from pathlib import Path
from shutil import rmtree
from urllib.parse import urlparse
from urllib.parse import urlsplit

from pyhf import exceptions

Expand Down Expand Up @@ -50,7 +50,7 @@ def download(archive_url, output_directory, force=False, compress=False):
"""
if not force:
valid_hosts = ["www.hepdata.net", "doi.org"]
netloc = urlparse(archive_url).netloc
netloc = urlsplit(archive_url).netloc
if netloc not in valid_hosts:
raise exceptions.InvalidArchiveHost(
f"{netloc} is not an approved archive host: {', '.join(str(host) for host in valid_hosts)}\n"
Expand Down

0 comments on commit 8219a84

Please sign in to comment.