@@ -191,6 +191,12 @@ class ShapeCastable:
191191 The source code of the :mod:`amaranth.lib.data` module can be used as a reference for
192192 implementing a fully featured shape-castable object.
193193 """
194+
195+ def __init__ (self , * args , ** kwargs ):
196+ if type (self ) is ShapeCastable :
197+ raise TypeError ("Can't instantiate abstract class ShapeCastable" )
198+ super ().__init__ (* args , ** kwargs )
199+
194200 def __init_subclass__ (cls , ** kwargs ):
195201 if cls .as_shape is ShapeCastable .as_shape :
196202 raise TypeError (f"Class '{ cls .__name__ } ' deriving from 'ShapeCastable' must override "
@@ -1616,6 +1622,12 @@ class ValueCastable:
16161622 from :class:`ValueCastable` is mutable, it is up to the user to ensure that it is not mutated
16171623 in a way that changes its representation after the first call to :meth:`as_value`.
16181624 """
1625+
1626+ def __init__ (self , * args , ** kwargs ):
1627+ if type (self ) is ValueCastable :
1628+ raise TypeError ("Can't instantiate abstract class ValueCastable" )
1629+ super ().__init__ (* args , ** kwargs )
1630+
16191631 def __init_subclass__ (cls , ** kwargs ):
16201632 if not hasattr (cls , "as_value" ):
16211633 raise TypeError (f"Class '{ cls .__name__ } ' deriving from `ValueCastable` must override "
0 commit comments