@@ -191,6 +191,12 @@ class ShapeCastable:
191
191
The source code of the :mod:`amaranth.lib.data` module can be used as a reference for
192
192
implementing a fully featured shape-castable object.
193
193
"""
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
+
194
200
def __init_subclass__ (cls , ** kwargs ):
195
201
if cls .as_shape is ShapeCastable .as_shape :
196
202
raise TypeError (f"Class '{ cls .__name__ } ' deriving from 'ShapeCastable' must override "
@@ -1616,6 +1622,12 @@ class ValueCastable:
1616
1622
from :class:`ValueCastable` is mutable, it is up to the user to ensure that it is not mutated
1617
1623
in a way that changes its representation after the first call to :meth:`as_value`.
1618
1624
"""
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
+
1619
1631
def __init_subclass__ (cls , ** kwargs ):
1620
1632
if not hasattr (cls , "as_value" ):
1621
1633
raise TypeError (f"Class '{ cls .__name__ } ' deriving from `ValueCastable` must override "
0 commit comments