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 <vapier@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Mike Frysinger 2023-10-19 05:13:32 -04:00 committed by LUCI
parent 024df06ec1
commit d4aee6570b
19 changed files with 43 additions and 43 deletions

View File

@ -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

View File

@ -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."""

View File

@ -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

View File

@ -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.

View File

@ -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__(

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -186,7 +186,7 @@ global_options.add_option(
)
class _Repo(object):
class _Repo:
def __init__(self, repodir):
self.repodir = repodir
self.commands = all_commands

View File

@ -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__(

View File

@ -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,

View File

@ -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 <copyfile> 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 <linkfile> 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 = []

6
repo
View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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):

View File

@ -48,7 +48,7 @@ def TempGitTree():
yield tempdir
class FakeProject(object):
class FakeProject:
"""A fake for Project for basic functionality."""
def __init__(self, worktree):