diff --git a/.flake8 b/.flake8 index 0f93acb7e..3eaf87807 100644 --- a/.flake8 +++ b/.flake8 @@ -7,7 +7,6 @@ per-file-ignores = # IMR241: When using the from syntax, only submodules are imported, not module elements. # NB: Do not add any more here. command.py: IMR241, - fetch.py: IMR241, git_command.py: IMR241, git_status.py: IMR241, git_superproject.py: IMR241, diff --git a/fetch.py b/fetch.py index 7e9a528b4..9c099428b 100644 --- a/fetch.py +++ b/fetch.py @@ -16,8 +16,8 @@ import subprocess import sys -from urllib.parse import urlparse -from urllib.request import urlopen +import urllib.parse +import urllib.request import error @@ -32,7 +32,7 @@ def fetch_file(url, verbose=False): Returns: The contents of the file as bytes. """ - scheme = urlparse(url).scheme + scheme = urllib.parse.urlparse(url).scheme if scheme == "gs": cmd = ["gcloud", "storage", "cat", url] errors = [] @@ -54,5 +54,5 @@ def fetch_file(url, verbose=False): file=sys.stderr, ) raise FetchFileError(aggregate_errors=errors) - with urlopen(url) as f: + with urllib.request.urlopen(url) as f: return f.read()