style: use import urllib.xxx everywhere

Align with Google style guides and `import urllib.xxx` as a module
rather than import symbols out of it.

Change-Id: Ia177f4fd5ee2a3f38f8a8860e9a2ba8beac8078f
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/654804
Reviewed-by: Brian Gan <brgan@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Commit-Queue: Mike Frysinger <vapier@google.com>
This commit is contained in:
Mike Frysinger authored and gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com committed 2026-11-06 11:56:05 -08:00
1 parent a4b44c5026
commit e15b3e0298
2 files changed
+4 -5

No files matched your search

-1
View File
@@ -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,
+4 -4
View File
@@ -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()