Repository: amaranth-lang/amaranth (python)

Issue:
`PureInterface.__repr__` should use the actual class name rather than always using "PureInterface"
The `__repr__` method was added in https://github.com/amaranth-lang/amaranth/pull/982, with this bug.

While writing the documentation I discovered that it is reasonably useful to inherit from `PureInterface` for really simple custom interfaces, and that we should probably recommend that. This inheritance pattern also matches up with what we'll do for `Component`.

Pull request description:
Fix `__repr__` for PureInterface subclasses
Fixes #988.

Patch:
diff --git a/amaranth/lib/wiring.py b/amaranth/lib/wiring.py
index 2a5a50c..0d94201 100644
--- a/amaranth/lib/wiring.py
+++ b/amaranth/lib/wiring.py
@@ -611,7 +611,7 @@ class PureInterface:
         attrs = ''.join(f", {name}={value!r}"
                         for name, value in self.__dict__.items()
                         if name != "signature")
-        return f'<PureInterface: {self.signature}{attrs}>'
+        return f'<{type(self).__name__}: {self.signature}{attrs}>'
 
 
 # To reduce API surface area `FlippedInterface` is made final. This restriction could be lifted


Test patch:
diff --git a/tests/test_lib_wiring.py b/tests/test_lib_wiring.py
index 105de56..ac6e2f0 100644
--- a/tests/test_lib_wiring.py
+++ b/tests/test_lib_wiring.py
@@ -671,6 +671,12 @@ class PureInterfaceTestCase(unittest.TestCase):
         intf = PureInterface(sig, path=("test",))
         self.assertEqual(repr(intf), "<PureInterface: Signature({'a': In(4), 'b': Out(signed(2))}), a=(sig test__a), b=(sig test__b)>")
 
+    def test_repr_inherit(self):
+        class CustomInterface(PureInterface):
+            pass
+        intf = CustomInterface(Signature({}), path=())
+        self.assertRegex(repr(intf), r"^<CustomInterface: .+?>$")
+
 
 class FlippedInterfaceTestCase(unittest.TestCase):
     def test_basic(self):