diff --git a/git_refs.py b/git_refs.py index 8e8d603a..bf7aa4a1 100644 --- a/git_refs.py +++ b/git_refs.py @@ -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 diff --git a/project.py b/project.py index 93d9dcba..5c9f31cf 100644 --- a/project.py +++ b/project.py @@ -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:") diff --git a/repo b/repo index 36a2e0ea..6b39f227 100755 --- a/repo +++ b/repo @@ -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.*)", line) if match: diff --git a/repo_trace.py b/repo_trace.py index d243ce6c..ee224ea7 100644 --- a/repo_trace.py +++ b/repo_trace.py @@ -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() diff --git a/subcmds/sync.py b/subcmds/sync.py index 1e87d152..23098972 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -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): diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py index 600b069f..478ebca7 100644 --- a/tests/test_git_superproject.py +++ b/tests/test_git_superproject.py @@ -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. diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index ef4dce10..ea7a8b4d 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py @@ -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),