From 0398c6718e8a17c374d868fbf253530bbc6ca13c Mon Sep 17 00:00:00 2001 From: Brian Gan Date: Tue, 7 Jul 2026 21:19:56 +0000 Subject: [PATCH] color: Replace anonymous sentinel with named class Replace the bare `object()` sentinel used for `_CHECK_CONSOLE` with an instance of a dedicated `_CheckConsoleSentinel` class. This gives the sentinel a meaningful repr and type, making it easier to identify in debugging output and type checks compared to an opaque ``. Change-Id: I916521d47ba13207e29a2412e00f3576aff8afff Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/605021 Commit-Queue: Brian Gan Tested-by: Brian Gan Reviewed-by: Gavin Mak --- color.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/color.py b/color.py index 406863453..53fadf0a1 100644 --- a/color.py +++ b/color.py @@ -84,9 +84,14 @@ def _Color(fg=None, bg=None, attr=None): DEFAULT = None + +class _CheckConsoleSentinel: + """Sentinel for checking console coloring.""" + + # Placholder value that indicates we need to check if the user is in an # interactive terminal session to determine if we turn on color or not. -_CHECK_CONSOLE = object() +_CHECK_CONSOLE = _CheckConsoleSentinel() # https://git-scm.com/docs/git-config#Documentation/git-config.txt-colorui _CONFIG_TO_COLOR_SETTING = {