def __format__(self, format_desc):
        """Forbidden formatting.

        Since normal Python formatting (f-strings and ``str.format``) must immediately return
        a string, it is unsuitable for formatting Amaranth values. To format a value at simulation
        time, use :class:`Format` instead. If you really want to dump the AST at elaboration time,
        use ``repr`` instead (for instance, via ``f"{value!r}"``).
        """
        raise TypeError(f"Value {self!r} cannot be converted to string. Use `Format` for "
                        f"simulation-time formatting, or use `repr` to print the AST.")
Forbidden formatting.

        Since normal Python formatting (f-strings and ``str.format``) must immediately return
        a string, it is unsuitable for formatting Amaranth values. To format a value at simulation
        time, use :class:`Format` instead. If you really want to dump the AST at elaboration time,
        use ``repr`` instead (for instance, via ``f"{value!r}"``).
        
amaranth/hdl/_ast.py