1414del _member
1515
1616
17- class EnumMeta (ShapeCastable , py_enum .EnumMeta ):
18- """Subclass of the standard :class:`enum.EnumMeta ` that implements the :class:`ShapeCastable`
17+ class EnumType (ShapeCastable , py_enum .EnumMeta ):
18+ """Subclass of the standard :class:`enum.EnumType ` that implements the :class:`ShapeCastable`
1919 protocol.
2020
2121 This metaclass provides the :meth:`as_shape` method, making its instances
2222 :ref:`shape-like <lang-shapelike>`, and accepts a ``shape=`` keyword argument
2323 to specify a shape explicitly. Other than this, it acts the same as the standard
24- :class:`enum.EnumMeta ` class; if the ``shape=`` argument is not specified and
24+ :class:`enum.EnumType ` class; if the ``shape=`` argument is not specified and
2525 :meth:`as_shape` is never called, it places no restrictions on the enumeration class
2626 or the values of its members.
2727
@@ -180,32 +180,37 @@ def _value_repr(cls, value):
180180 yield Repr (FormatEnum (cls ), value )
181181
182182
183+ # In 3.11, Python renamed EnumMeta to EnumType. Like Python itself, we support both for
184+ # compatibility.
185+ EnumMeta = EnumType
186+
187+
183188class Enum (py_enum .Enum ):
184- """Subclass of the standard :class:`enum.Enum` that has :class:`EnumMeta ` as
189+ """Subclass of the standard :class:`enum.Enum` that has :class:`EnumType ` as
185190 its metaclass and :class:`EnumView` as its view class."""
186191
187192
188193class IntEnum (py_enum .IntEnum ):
189- """Subclass of the standard :class:`enum.IntEnum` that has :class:`EnumMeta ` as
194+ """Subclass of the standard :class:`enum.IntEnum` that has :class:`EnumType ` as
190195 its metaclass."""
191196
192197
193198class Flag (py_enum .Flag ):
194- """Subclass of the standard :class:`enum.Flag` that has :class:`EnumMeta ` as
199+ """Subclass of the standard :class:`enum.Flag` that has :class:`EnumType ` as
195200 its metaclass and :class:`FlagView` as its view class."""
196201
197202
198203class IntFlag (py_enum .IntFlag ):
199- """Subclass of the standard :class:`enum.IntFlag` that has :class:`EnumMeta ` as
204+ """Subclass of the standard :class:`enum.IntFlag` that has :class:`EnumType ` as
200205 its metaclass."""
201206
202207
203208# Fix up the metaclass after the fact: the metaclass __new__ requires these classes
204209# to already be present, and also would not install itself on them due to lack of shape.
205- Enum .__class__ = EnumMeta
206- IntEnum .__class__ = EnumMeta
207- Flag .__class__ = EnumMeta
208- IntFlag .__class__ = EnumMeta
210+ Enum .__class__ = EnumType
211+ IntEnum .__class__ = EnumType
212+ Flag .__class__ = EnumType
213+ IntFlag .__class__ = EnumType
209214
210215
211216class EnumView (ValueCastable ):
@@ -219,7 +224,7 @@ def __init__(self, enum, target):
219224 """Constructs a view with the given enum type and target
220225 (a :ref:`value-like <lang-valuelike>`).
221226 """
222- if not isinstance (enum , EnumMeta ) or not hasattr (enum , "_amaranth_shape_" ):
227+ if not isinstance (enum , EnumType ) or not hasattr (enum , "_amaranth_shape_" ):
223228 raise TypeError (f"EnumView type must be an enum with shape, not { enum !r} " )
224229 try :
225230 cast_target = Value .cast (target )
0 commit comments