Repository: nosarthur/gita (language: python)

Issue:
Color printing does not work with Python 3.11 
Since 3.11 using `f"{Color.foo}"` prints `Color.foo` instead of inserting `Color.foo.value`. For instance:

```sh
$ gita ll -h
[...]
 branch colors:
    Color.whitewhiteColor.end: local has no remote
    Color.greengreenColor.end: local is the same as remote
    Color.redredColor.end: local has diverged from remote
    Color.purplepurpleColor.end: local is ahead of remote (good for push)
    Color.yellowyellowColor.end: local is behind remote (good for merge)
```


Discussion / hints:

Fix patch:
diff --git a/gita/info.py b/gita/info.py
index ee302d0..57bb1a8 100644
--- a/gita/info.py
+++ b/gita/info.py
@@ -9,7 +9,7 @@
 from . import common
 
 
-class Color(str, Enum):
+class Color(Enum):
     """
     Terminal color
     """
@@ -32,6 +32,12 @@ class Color(str, Enum):
     b_white = '\x1b[37;1m'
     underline = '\x1B[4m'
 
+    # Make f"{Color.foo}" expand to Color.foo.value .
+    #
+    # See https://stackoverflow.com/a/24487545
+    def __str__(self):
+        return f"{self.value}"
+
 
 default_colors = {
             'no-remote': Color.white.name,


Test patch:
diff --git a/tests/test_main.py b/tests/test_main.py
index 4da5644..0f2eeb5 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -94,14 +94,14 @@ def side_effect(input, _=None):
         out, err = capfd.readouterr()
         assert err == ""
         assert "gita" in out
-        assert info.Color.end in out
+        assert info.Color.end.value in out
 
         # no color on branch name
         __main__.main(["ll", "-C"])
         out, err = capfd.readouterr()
         assert err == ""
         assert "gita" in out
-        assert info.Color.end not in out
+        assert info.Color.end.value not in out
 
         __main__.main(["ls", "gita"])
         out, err = capfd.readouterr()