style: use import color everywhere

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

Change-Id: Id3f1f8ea324097d6e1ea5ed33c67b4b024abce7f
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/654810
Commit-Queue: Mike Frysinger <vapier@google.com>
Reviewed-by: Brian Gan <brgan@google.com>
Tested-by: 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-09 09:07:27 -08:00
1 parent 9d01d216e0
commit c382d3807a
17 files changed
+48 -50

No files matched your search

-2
View File
@@ -14,7 +14,6 @@ per-file-ignores =
main.py: IMR241,
manifest_xml.py: IMR241,
project.py: IMR241,
repo_logging.py: IMR241,
subcmds/abandon.py: IMR241,
subcmds/branches.py: IMR241,
subcmds/checkout.py: IMR241,
@@ -52,7 +51,6 @@ per-file-ignores =
tests/test_command.py: IMR241,
tests/test_error.py: IMR241,
tests/test_main.py: IMR241,
tests/test_repo_logging.py: IMR241,
tests/test_subcmds.py: IMR241,
tests/test_subcmds_sync.py: IMR241,
extend-ignore =
+2 -2
View File
@@ -41,7 +41,7 @@ try:
except ImportError:
kerberos = None
from color import SetDefaultColoring
import color
from command import InteractiveCommand
from command import MirrorSafeCommand
import editor
@@ -387,7 +387,7 @@ class _Repo:
def _RunLong(self, name, gopts, argv, git_trace2_event_log):
"""Execute the (longer running) requested subcommand."""
result = 0
SetDefaultColoring(gopts.color)
color.SetDefaultColoring(gopts.color)
outer_client = RepoClient(self.repodir)
repo_client = outer_client
+4 -4
View File
@@ -32,7 +32,7 @@ import time
from typing import Any, Dict, List, NamedTuple, Optional, Tuple
import urllib.parse
from color import Coloring
import color
import error
import fetch
import git_command
@@ -382,7 +382,7 @@ class ReviewableBranch:
return refs
class StatusColoring(Coloring):
class StatusColoring(color.Coloring):
def __init__(self, config):
super().__init__(config, "status")
self.project = self.printer("header", attr="bold")
@@ -395,7 +395,7 @@ class StatusColoring(Coloring):
self.untracked = self.printer("untracked", fg="red")
class DiffColoring(Coloring):
class DiffColoring(color.Coloring):
def __init__(self, config):
super().__init__(config, "diff")
self.project = self.printer("header", attr="bold")
@@ -5512,7 +5512,7 @@ class _Later:
return False
class _SyncColoring(Coloring):
class _SyncColoring(color.Coloring):
def __init__(self, config):
super().__init__(config, "reposync")
self.project = self.printer("header", attr="bold")
+2 -2
View File
@@ -16,7 +16,7 @@
import logging
from color import Coloring
import color
import error
@@ -34,7 +34,7 @@ class _ConfigMock:
return self.default_values.get(x, None)
class _LogColoring(Coloring):
class _LogColoring(color.Coloring):
"""Coloring outstream for logging."""
def __init__(self, config):
+3 -3
View File
@@ -15,14 +15,14 @@
import itertools
import sys
from color import Coloring
import color
from command import Command
from command import DEFAULT_LOCAL_JOBS
class BranchColoring(Coloring):
class BranchColoring(color.Coloring):
def __init__(self, config):
Coloring.__init__(self, config, "branch")
super().__init__(config, "branch")
self.current = self.printer("current", fg="green")
self.local = self.printer("local")
self.notinproject = self.printer("notinproject", fg="red")
+3 -3
View File
@@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from color import Coloring
import color
from command import PagedCommand
from manifest_xml import RepoClient
class _Coloring(Coloring):
class _Coloring(color.Coloring):
def __init__(self, config):
Coloring.__init__(self, config, "status")
super().__init__(config, "status")
class Diffmanifests(PagedCommand):
+5 -5
View File
@@ -21,7 +21,7 @@ import signal
import subprocess
import sys
from color import Coloring
import color
from command import Command
from command import DEFAULT_LOCAL_JOBS
from command import MirrorSafeCommand
@@ -37,9 +37,9 @@ _CAN_COLOR = [
]
class ForallColoring(Coloring):
class ForallColoring(color.Coloring):
def __init__(self, config):
Coloring.__init__(self, config, "forall")
super().__init__(config, "forall")
self.project = self.printer("project", attr="bold")
@@ -234,9 +234,9 @@ without iterating through the remaining projects.
cn = None
if cn and cn in _CAN_COLOR:
class ColorCmd(Coloring):
class ColorCmd(color.Coloring):
def __init__(self, config, cmd):
Coloring.__init__(self, config, cmd)
super().__init__(config, cmd)
if ColorCmd(self.manifest.manifestProject.config, cn).is_on:
cmd.insert(cmd.index(cn) + 1, "--color")
+3 -3
View File
@@ -16,7 +16,7 @@ import functools
import sys
from typing import NamedTuple
from color import Coloring
import color
from command import DEFAULT_LOCAL_JOBS
from command import PagedCommand
import error
@@ -27,9 +27,9 @@ import repo_logging
logger = repo_logging.RepoLogger(__file__)
class GrepColoring(Coloring):
class GrepColoring(color.Coloring):
def __init__(self, config):
Coloring.__init__(self, config, "grep")
super().__init__(config, "grep")
self.project = self.printer("project", attr="bold")
self.fail = self.printer("fail", fg="red")
+3 -3
View File
@@ -16,7 +16,7 @@ import re
import sys
import textwrap
from color import Coloring
import color
from command import MirrorSafeCommand
from command import PagedCommand
import error
@@ -87,9 +87,9 @@ Displays detailed usage information about a command.
print("Bug reports:", Wrapper().BUG_URL)
def _PrintCommandHelp(self, cmd, header_prefix=""):
class _Out(Coloring):
class _Out(color.Coloring):
def __init__(self, gc):
Coloring.__init__(self, gc, "help")
super().__init__(gc, "help")
self.heading = self.printer("heading", attr="bold")
self._first = True
+3 -3
View File
@@ -20,7 +20,7 @@ import optparse
import sys
from typing import Any, Dict, List, NamedTuple, Optional, Tuple
from color import Coloring
import color
from command import DEFAULT_LOCAL_JOBS
from command import PagedCommand
import git_refs
@@ -46,9 +46,9 @@ class OutputFormat(enum.Enum):
JSON = enum.auto()
class _Coloring(Coloring):
class _Coloring(color.Coloring):
def __init__(self, config):
Coloring.__init__(self, config, "status")
super().__init__(config, "status")
class Info(PagedCommand):
+3 -3
View File
@@ -15,7 +15,7 @@
import os
import sys
from color import Coloring
import color
from command import InteractiveCommand
from command import MirrorSafeCommand
import error
@@ -244,9 +244,9 @@ to update the working directory files.
if self._HasColorSet(gc):
return
class _Test(Coloring):
class _Test(color.Coloring):
def __init__(self):
Coloring.__init__(self, gc, "test color display")
super().__init__(gc, "test color display")
self._on = True
out = _Test()
+3 -3
View File
@@ -14,7 +14,7 @@
import optparse
from color import Coloring
import color
from command import PagedCommand
@@ -73,9 +73,9 @@ are displayed.
if not all_branches:
return
class Report(Coloring):
class Report(color.Coloring):
def __init__(self, config):
Coloring.__init__(self, config, "status")
super().__init__(config, "status")
self.project = self.printer("header", attr="bold")
self.text = self.printer("text")
+3 -3
View File
@@ -14,7 +14,7 @@
import itertools
from color import Coloring
import color
from command import DEFAULT_LOCAL_JOBS
from command import PagedCommand
@@ -56,9 +56,9 @@ class Prune(PagedCommand):
if not all_branches:
return
class Report(Coloring):
class Report(color.Coloring):
def __init__(self, config):
Coloring.__init__(self, config, "status")
super().__init__(config, "status")
self.project = self.printer("header", attr="bold")
out = Report(all_branches[0].project.config)
+3 -3
View File
@@ -14,7 +14,7 @@
import sys
from color import Coloring
import color
from command import Command
import error
import git_command
@@ -25,9 +25,9 @@ import repo_logging
logger = repo_logging.RepoLogger(__file__)
class RebaseColoring(Coloring):
class RebaseColoring(color.Coloring):
def __init__(self, config):
Coloring.__init__(self, config, "rebase")
super().__init__(config, "rebase")
self.project = self.printer("project", attr="bold")
self.fail = self.printer("fail", fg="red")
+3 -3
View File
@@ -14,7 +14,7 @@
import sys
from color import Coloring
import color
from command import InteractiveCommand
import git_command
import repo_logging
@@ -23,9 +23,9 @@ import repo_logging
logger = repo_logging.RepoLogger(__file__)
class _ProjectList(Coloring):
class _ProjectList(color.Coloring):
def __init__(self, gc):
Coloring.__init__(self, gc, "interactive")
super().__init__(gc, "interactive")
self.prompt = self.printer("prompt", fg="blue", attr="bold")
self.header = self.printer("header", attr="bold")
self.help = self.printer("help", fg="red", attr="bold")
+3 -3
View File
@@ -17,7 +17,7 @@ import glob
import io
import os
from color import Coloring
import color
from command import DEFAULT_LOCAL_JOBS
from command import PagedCommand
import platform_utils
@@ -180,9 +180,9 @@ the following meanings:
(head, _tail) = os.path.split(head)
proj_dirs.add(".repo")
class StatusColoring(Coloring):
class StatusColoring(color.Coloring):
def __init__(self, config):
Coloring.__init__(self, config, "status")
super().__init__(config, "status")
self.project = self.printer("header", attr="bold")
self.untracked = self.printer("untracked", fg="red")
+2 -2
View File
@@ -22,7 +22,7 @@ from unittest import mock
import pytest
from color import SetDefaultColoring
import color
import error
import repo_logging
@@ -86,7 +86,7 @@ def test_log_with_format_string(level: int) -> None:
# Set color output to "always" for consistent test results.
# This ensures the logger's behavior is uniform across different
# environments and git configurations.
SetDefaultColoring("always")
color.SetDefaultColoring("always")
# Regex pattern to match optional ANSI color codes.
# \033 - Escape character