style: use import editor everywhere

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

Change-Id: Ie941ff12f63c2b168bcec6510751e155156f26e7
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/654807
Reviewed-by: Brian Gan <brgan@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Commit-Queue: 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 07:09:25 -08:00
1 parent 2029997aef
commit 3a3d1fc7cd
4 files changed
+13 -14

No files matched your search

-1
View File
@@ -50,7 +50,6 @@ per-file-ignores =
tests/e2e/test_sync_modes.py: IMR241,
tests/e2e/test_workflows.py: IMR241,
tests/test_command.py: IMR241,
tests/test_editor.py: IMR241,
tests/test_error.py: IMR241,
tests/test_main.py: IMR241,
tests/test_repo_logging.py: IMR241,
+2 -2
View File
@@ -44,7 +44,7 @@ except ImportError:
from color import SetDefaultColoring
from command import InteractiveCommand
from command import MirrorSafeCommand
from editor import Editor
import editor
import error
import event_log
import git_command
@@ -417,7 +417,7 @@ class _Repo:
)
cmd.event_log.enabled = bool(gopts.event_log)
Editor.globalConfig = cmd.client.globalConfig
editor.Editor.globalConfig = cmd.client.globalConfig
if not isinstance(cmd, MirrorSafeCommand) and cmd.manifest.IsMirror:
logger.error("fatal: '%s' requires a working directory", name)
+2 -2
View File
@@ -21,7 +21,7 @@ from typing import List
from command import DEFAULT_LOCAL_JOBS
from command import InteractiveCommand
from editor import Editor
import editor
import error
import git_refs
import git_superproject
@@ -494,7 +494,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
branches[project_path] = b
script.append("")
script = Editor.EditString("\n".join(script)).split("\n")
script = editor.Editor.EditString("\n".join(script)).split("\n")
project_re = re.compile(r"^#?\s*project\s*([^\s]+)/:$")
branch_re = re.compile(r"^\s*branch\s*([^\s(]+)\s*\(.*")
+9 -9
View File
@@ -16,30 +16,30 @@
import pytest
from editor import Editor
import editor
@pytest.fixture(autouse=True)
def reset_editor() -> None:
"""Take care of resetting Editor state across tests."""
Editor._editor = None
editor.Editor._editor = None
yield
Editor._editor = None
editor.Editor._editor = None
def test_basic() -> None:
"""Basic checking of _GetEditor."""
Editor._editor = ":"
assert Editor._GetEditor() == ":"
editor.Editor._editor = ":"
assert editor.Editor._GetEditor() == ":"
def test_no_editor() -> None:
"""Check behavior when no editor is available."""
Editor._editor = ":"
assert Editor.EditString("foo") == "foo"
editor.Editor._editor = ":"
assert editor.Editor.EditString("foo") == "foo"
def test_cat_editor() -> None:
"""Check behavior when editor is `cat`."""
Editor._editor = "cat"
assert Editor.EditString("foo") == "foo"
editor.Editor._editor = "cat"
assert editor.Editor.EditString("foo") == "foo"