cleanup: delete redundant "r" open mode

Change-Id: I86ebb8c5a9dc3752e8a25f4b11b64c5be3a6429e
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390375
Tested-by: Mike Frysinger <vapier@google.com>
Commit-Queue: Mike Frysinger <vapier@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
This commit is contained in:
Jason R. Coombs 2023-10-20 23:32:02 +05:45 committed by LUCI
parent 0bcffd8656
commit 034950b9ee
7 changed files with 10 additions and 10 deletions

View File

@ -105,7 +105,7 @@ class GitRefs:
def _ReadPackedRefs(self):
path = os.path.join(self._gitdir, "packed-refs")
try:
fd = open(path, "r")
fd = open(path)
mtime = os.path.getmtime(path)
except IOError:
return

View File

@ -3227,7 +3227,7 @@ class Project:
# Rewrite the internal state files to use relative paths between the
# checkouts & worktrees.
dotgit = os.path.join(self.worktree, ".git")
with open(dotgit, "r") as fp:
with open(dotgit) as fp:
# Figure out the checkout->worktree path.
setting = fp.read()
assert setting.startswith("gitdir:")

2
repo
View File

@ -622,7 +622,7 @@ def get_gitc_manifest_dir():
if _gitc_manifest_dir is None:
_gitc_manifest_dir = ""
try:
with open(GITC_CONFIG_FILE, "r") as gitc_config:
with open(GITC_CONFIG_FILE) as gitc_config:
for line in gitc_config:
match = re.match("gitc_dir=(?P<gitc_manifest_dir>.*)", line)
if match:

View File

@ -142,7 +142,7 @@ def _GetTraceFile(quiet):
def _ClearOldTraces():
"""Clear the oldest commands if trace file is too big."""
try:
with open(_TRACE_FILE, "r", errors="ignore") as f:
with open(_TRACE_FILE, errors="ignore") as f:
if os.path.getsize(f.name) / (1024 * 1024) <= _MAX_SIZE:
return
trace_lines = f.readlines()

View File

@ -1265,7 +1265,7 @@ later is required to fix a server side protocol bug.
old_project_paths = []
if os.path.exists(file_path):
with open(file_path, "r") as fd:
with open(file_path) as fd:
old_project_paths = fd.read().split("\n")
# In reversed order, so subfolders are deleted before parent folder.
for path in sorted(old_project_paths, reverse=True):

View File

@ -249,7 +249,7 @@ class SuperprojectTestCase(unittest.TestCase):
os.mkdir(self._superproject._superproject_path)
manifest_path = self._superproject._WriteManifestFile()
self.assertIsNotNone(manifest_path)
with open(manifest_path, "r") as fp:
with open(manifest_path) as fp:
manifest_xml_data = fp.read()
self.assertEqual(
sort_attributes(manifest_xml_data),
@ -284,7 +284,7 @@ class SuperprojectTestCase(unittest.TestCase):
)
self.assertIsNotNone(update_result.manifest_path)
self.assertFalse(update_result.fatal)
with open(update_result.manifest_path, "r") as fp:
with open(update_result.manifest_path) as fp:
manifest_xml_data = fp.read()
self.assertEqual(
sort_attributes(manifest_xml_data),
@ -371,7 +371,7 @@ class SuperprojectTestCase(unittest.TestCase):
)
self.assertIsNotNone(update_result.manifest_path)
self.assertFalse(update_result.fatal)
with open(update_result.manifest_path, "r") as fp:
with open(update_result.manifest_path) as fp:
manifest_xml_data = fp.read()
# Verify platform/vendor/x's project revision hasn't
# changed.
@ -436,7 +436,7 @@ class SuperprojectTestCase(unittest.TestCase):
)
self.assertIsNotNone(update_result.manifest_path)
self.assertFalse(update_result.fatal)
with open(update_result.manifest_path, "r") as fp:
with open(update_result.manifest_path) as fp:
manifest_xml_data = fp.read()
# Verify platform/vendor/x's project revision hasn't
# changed.

View File

@ -418,7 +418,7 @@ class SetupGnuPG(RepoWrapperTestCase):
self.wrapper.home_dot_repo, "gnupg"
)
self.assertTrue(self.wrapper.SetupGnuPG(True))
with open(os.path.join(tempdir, "keyring-version"), "r") as fp:
with open(os.path.join(tempdir, "keyring-version")) as fp:
data = fp.read()
self.assertEqual(
".".join(str(x) for x in self.wrapper.KEYRING_VERSION),