From d4aee6570b64c5b6de584b0a5ce76e6a139faf38 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 19 Oct 2023 05:13:32 -0400 Subject: delete Python 2 (object) compat Bug: 302871152 Change-Id: I39636d73a6e1d69efa8ade74f75c5381651e6dc8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390054 Commit-Queue: Mike Frysinger Reviewed-by: Aravind Vasudevan Tested-by: Mike Frysinger --- color.py | 2 +- command.py | 6 +++--- editor.py | 2 +- event_log.py | 2 +- git_command.py | 6 +++--- git_config.py | 8 ++++---- git_refs.py | 2 +- git_superproject.py | 2 +- git_trace2_event_log_base.py | 2 +- hooks.py | 2 +- main.py | 2 +- manifest_xml.py | 6 +++--- progress.py | 2 +- project.py | 26 +++++++++++++------------- repo | 6 +++--- subcmds/branches.py | 2 +- subcmds/sync.py | 4 ++-- tests/test_git_command.py | 2 +- tests/test_project.py | 2 +- 19 files changed, 43 insertions(+), 43 deletions(-) diff --git a/color.py b/color.py index 0f637489..e3e2a5f3 100644 --- a/color.py +++ b/color.py @@ -103,7 +103,7 @@ def SetDefaultColoring(state): DEFAULT = "never" -class Coloring(object): +class Coloring: def __init__(self, config, section_type): self._section = "color.%s" % section_type self._config = config diff --git a/command.py b/command.py index 9d5d56ee..a6189ed6 100644 --- a/command.py +++ b/command.py @@ -46,7 +46,7 @@ class UsageError(RepoExitError): """Exception thrown with invalid command usage.""" -class Command(object): +class Command: """Base class for any command line action in repo.""" # Singleton for all commands to track overall repo command execution and @@ -498,11 +498,11 @@ class PagedCommand(Command): return True -class MirrorSafeCommand(object): +class MirrorSafeCommand: """Command permits itself to run within a mirror, and does not require a working directory. """ -class GitcClientCommand(object): +class GitcClientCommand: """Command that requires the local client to be a GITC client.""" diff --git a/editor.py b/editor.py index 78311f1a..10ff158b 100644 --- a/editor.py +++ b/editor.py @@ -22,7 +22,7 @@ from error import EditorError import platform_utils -class Editor(object): +class Editor: """Manages the user's preferred text editor.""" _editor = None diff --git a/event_log.py b/event_log.py index 60c1a437..ef01394a 100644 --- a/event_log.py +++ b/event_log.py @@ -21,7 +21,7 @@ TASK_SYNC_NETWORK = "sync-network" TASK_SYNC_LOCAL = "sync-local" -class EventLog(object): +class EventLog: """Event log that records events that occurred during a repo invocation. Events are written to the log as a consecutive JSON entries, one per line. diff --git a/git_command.py b/git_command.py index 2e4974fa..0e256392 100644 --- a/git_command.py +++ b/git_command.py @@ -58,7 +58,7 @@ INVALID_GIT_EXIT_CODE = 126 logger = RepoLogger(__file__) -class _GitCall(object): +class _GitCall: @functools.lru_cache(maxsize=None) def version_tuple(self): ret = Wrapper().ParseGitVersion() @@ -148,7 +148,7 @@ def GetEventTargetPath(): return path -class UserAgent(object): +class UserAgent: """Mange User-Agent settings when talking to external services We follow the style as documented here: @@ -272,7 +272,7 @@ def _build_env( return env -class GitCommand(object): +class GitCommand: """Wrapper around a single git invocation.""" def __init__( diff --git a/git_config.py b/git_config.py index c19f7662..4f053ed0 100644 --- a/git_config.py +++ b/git_config.py @@ -70,7 +70,7 @@ def _key(name): return ".".join(parts) -class GitConfig(object): +class GitConfig: _ForUser = None _ForSystem = None @@ -430,7 +430,7 @@ class RepoConfig(GitConfig): return os.path.join(repo_config_dir, ".repoconfig/config") -class RefSpec(object): +class RefSpec: """A Git refspec line, split into its components: forced: True if the line starts with '+' @@ -541,7 +541,7 @@ def GetUrlCookieFile(url, quiet): yield cookiefile, None -class Remote(object): +class Remote: """Configuration options related to a remote.""" def __init__(self, config, name): @@ -723,7 +723,7 @@ class Remote(object): return self._config.GetString(key, all_keys=all_keys) -class Branch(object): +class Branch: """Configuration options related to a single branch.""" def __init__(self, config, name): diff --git a/git_refs.py b/git_refs.py index 1f5eaab4..8e8d603a 100644 --- a/git_refs.py +++ b/git_refs.py @@ -28,7 +28,7 @@ R_WORKTREE_M = R_WORKTREE + "m/" R_M = "refs/remotes/m/" -class GitRefs(object): +class GitRefs: def __init__(self, gitdir): self._gitdir = gitdir self._phyref = None diff --git a/git_superproject.py b/git_superproject.py index 5d8c0d4e..651b6dbb 100644 --- a/git_superproject.py +++ b/git_superproject.py @@ -66,7 +66,7 @@ class UpdateProjectsResult(NamedTuple): fatal: bool -class Superproject(object): +class Superproject: """Get commit ids from superproject. Initializes a local copy of a superproject for the manifest. This allows diff --git a/git_trace2_event_log_base.py b/git_trace2_event_log_base.py index d986b240..7b51b753 100644 --- a/git_trace2_event_log_base.py +++ b/git_trace2_event_log_base.py @@ -42,7 +42,7 @@ import threading p_init_count = 0 -class BaseEventLog(object): +class BaseEventLog: """Event log that records events that occurred during a repo invocation. Events are written to the log as a consecutive JSON entries, one per line. diff --git a/hooks.py b/hooks.py index 337c2627..6ded08b9 100644 --- a/hooks.py +++ b/hooks.py @@ -22,7 +22,7 @@ from error import HookError from git_refs import HEAD -class RepoHook(object): +class RepoHook: """A RepoHook contains information about a script to run as a hook. Hooks are used to run a python script before running an upload (for diff --git a/main.py b/main.py index 07c360f4..a1282851 100755 --- a/main.py +++ b/main.py @@ -186,7 +186,7 @@ global_options.add_option( ) -class _Repo(object): +class _Repo: def __init__(self, repodir): self.repodir = repodir self.commands = all_commands diff --git a/manifest_xml.py b/manifest_xml.py index 458dfb7d..d2217bb8 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -119,7 +119,7 @@ def XmlInt(node, attr, default=None): ) -class _Default(object): +class _Default: """Project defaults within the manifest.""" revisionExpr = None @@ -142,7 +142,7 @@ class _Default(object): return self.__dict__ != other.__dict__ -class _XmlRemote(object): +class _XmlRemote: def __init__( self, name, @@ -354,7 +354,7 @@ class SubmanifestSpec: self.groups = groups or [] -class XmlManifest(object): +class XmlManifest: """manages the repo configuration file""" def __init__( diff --git a/progress.py b/progress.py index 80bc9463..54eb8f93 100644 --- a/progress.py +++ b/progress.py @@ -82,7 +82,7 @@ def jobs_str(total): return f"{total} job{'s' if total > 1 else ''}" -class Progress(object): +class Progress: def __init__( self, title, diff --git a/project.py b/project.py index 80c20add..c91ae217 100644 --- a/project.py +++ b/project.py @@ -152,7 +152,7 @@ def _ProjectHooks(): return _project_hook_list -class DownloadedChange(object): +class DownloadedChange: _commit_cache = None def __init__(self, project, base, change_id, ps_id, commit): @@ -178,7 +178,7 @@ class DownloadedChange(object): return self._commit_cache -class ReviewableBranch(object): +class ReviewableBranch: _commit_cache = None _base_exists = None @@ -319,7 +319,7 @@ class DiffColoring(Coloring): self.fail = self.printer("fail", fg="red") -class Annotation(object): +class Annotation: def __init__(self, name, value, keep): self.name = name self.value = value @@ -386,7 +386,7 @@ def _SafeExpandPath(base, subpath, skipfinal=False): return path -class _CopyFile(object): +class _CopyFile: """Container for manifest element.""" def __init__(self, git_worktree, src, topdir, dest): @@ -435,7 +435,7 @@ class _CopyFile(object): logger.error("error: Cannot copy file %s to %s", src, dest) -class _LinkFile(object): +class _LinkFile: """Container for manifest element.""" def __init__(self, git_worktree, src, topdir, dest): @@ -518,7 +518,7 @@ class _LinkFile(object): self.__linkIt(relSrc, absDest) -class RemoteSpec(object): +class RemoteSpec: def __init__( self, name, @@ -538,7 +538,7 @@ class RemoteSpec(object): self.fetchUrl = fetchUrl -class Project(object): +class Project: # These objects can be shared between several working trees. @property def shareable_dirs(self): @@ -3475,7 +3475,7 @@ class Project(object): ) return logs - class _GitGetByExec(object): + class _GitGetByExec: def __init__(self, project, bare, gitdir): self._project = project self._bare = bare @@ -3530,7 +3530,7 @@ class Project(object): except StopIteration: break - class _Info(object): + class _Info: def __init__(self, path, omode, nmode, oid, nid, state): self.path = path self.src_path = None @@ -3716,7 +3716,7 @@ class _DirtyError(LocalSyncFail): return "contains uncommitted changes" -class _InfoMessage(object): +class _InfoMessage: def __init__(self, project, text): self.project = project self.text = text @@ -3728,7 +3728,7 @@ class _InfoMessage(object): syncbuf.out.nl() -class _Failure(object): +class _Failure: def __init__(self, project, why): self.project = project self.why = why @@ -3740,7 +3740,7 @@ class _Failure(object): syncbuf.out.nl() -class _Later(object): +class _Later: def __init__(self, project, action): self.project = project self.action = action @@ -3766,7 +3766,7 @@ class _SyncColoring(Coloring): self.fail = self.printer("fail", fg="red") -class SyncBuffer(object): +class SyncBuffer: def __init__(self, config, detach_head=False): self._messages = [] self._failures = [] diff --git a/repo b/repo index 7f24ff1e..95f9df88 100755 --- a/repo +++ b/repo @@ -40,7 +40,7 @@ MIN_PYTHON_VERSION_HARD = (3, 5) # Keep basic logic in sync with repo_trace.py. -class Trace(object): +class Trace: """Trace helper logic.""" REPO_TRACE = "REPO_TRACE" @@ -1214,7 +1214,7 @@ def _FindRepo(): return (repo, os.path.join(curdir, repodir)) -class _Options(object): +class _Options: help = False version = False @@ -1258,7 +1258,7 @@ def _ParseArguments(args): return cmd, opt, arg -class Requirements(object): +class Requirements: """Helper for checking repo's system requirements.""" REQUIREMENTS_NAME = "requirements.json" diff --git a/subcmds/branches.py b/subcmds/branches.py index 33523c38..d9a190be 100644 --- a/subcmds/branches.py +++ b/subcmds/branches.py @@ -28,7 +28,7 @@ class BranchColoring(Coloring): self.notinproject = self.printer("notinproject", fg="red") -class BranchInfo(object): +class BranchInfo: def __init__(self, name): self.name = name self.current = 0 diff --git a/subcmds/sync.py b/subcmds/sync.py index e1f7d019..dbdaa2c2 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -1908,7 +1908,7 @@ def _PostRepoFetch(rp, repo_verify=True, verbose=False): print("repo version %s is current" % rp.work_git.describe(HEAD)) -class _FetchTimes(object): +class _FetchTimes: _ALPHA = 0.5 def __init__(self, manifest): @@ -1951,7 +1951,7 @@ class _FetchTimes(object): platform_utils.remove(self._path, missing_ok=True) -class LocalSyncState(object): +class LocalSyncState: _LAST_FETCH = "last_fetch" _LAST_CHECKOUT = "last_checkout" diff --git a/tests/test_git_command.py b/tests/test_git_command.py index 881cccb8..7c108ccd 100644 --- a/tests/test_git_command.py +++ b/tests/test_git_command.py @@ -72,7 +72,7 @@ class GitCommandWaitTest(unittest.TestCase): """Tests the GitCommand class .Wait()""" def setUp(self): - class MockPopen(object): + class MockPopen: rc = 0 def __init__(self): diff --git a/tests/test_project.py b/tests/test_project.py index 79728d70..42f0f6e5 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -48,7 +48,7 @@ def TempGitTree(): yield tempdir -class FakeProject(object): +class FakeProject: """A fake for Project for basic functionality.""" def __init__(self, worktree): -- cgit v1.2.3-54-g00ecf