14
14
del _member
15
15
16
16
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`
19
19
protocol.
20
20
21
21
This metaclass provides the :meth:`as_shape` method, making its instances
22
22
:ref:`shape-like <lang-shapelike>`, and accepts a ``shape=`` keyword argument
23
23
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
25
25
:meth:`as_shape` is never called, it places no restrictions on the enumeration class
26
26
or the values of its members.
27
27
@@ -180,32 +180,35 @@ def _value_repr(cls, value):
180
180
yield Repr (FormatEnum (cls ), value )
181
181
182
182
183
+ EnumMeta = EnumType
184
+
185
+
183
186
class Enum (py_enum .Enum ):
184
- """Subclass of the standard :class:`enum.Enum` that has :class:`EnumMeta ` as
187
+ """Subclass of the standard :class:`enum.Enum` that has :class:`EnumType ` as
185
188
its metaclass and :class:`EnumView` as its view class."""
186
189
187
190
188
191
class IntEnum (py_enum .IntEnum ):
189
- """Subclass of the standard :class:`enum.IntEnum` that has :class:`EnumMeta ` as
192
+ """Subclass of the standard :class:`enum.IntEnum` that has :class:`EnumType ` as
190
193
its metaclass."""
191
194
192
195
193
196
class Flag (py_enum .Flag ):
194
- """Subclass of the standard :class:`enum.Flag` that has :class:`EnumMeta ` as
197
+ """Subclass of the standard :class:`enum.Flag` that has :class:`EnumType ` as
195
198
its metaclass and :class:`FlagView` as its view class."""
196
199
197
200
198
201
class IntFlag (py_enum .IntFlag ):
199
- """Subclass of the standard :class:`enum.IntFlag` that has :class:`EnumMeta ` as
202
+ """Subclass of the standard :class:`enum.IntFlag` that has :class:`EnumType ` as
200
203
its metaclass."""
201
204
202
205
203
206
# Fix up the metaclass after the fact: the metaclass __new__ requires these classes
204
207
# 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
208
+ Enum .__class__ = EnumType
209
+ IntEnum .__class__ = EnumType
210
+ Flag .__class__ = EnumType
211
+ IntFlag .__class__ = EnumType
209
212
210
213
211
214
class EnumView (ValueCastable ):
@@ -219,7 +222,7 @@ def __init__(self, enum, target):
219
222
"""Constructs a view with the given enum type and target
220
223
(a :ref:`value-like <lang-valuelike>`).
221
224
"""
222
- if not isinstance (enum , EnumMeta ) or not hasattr (enum , "_amaranth_shape_" ):
225
+ if not isinstance (enum , EnumType ) or not hasattr (enum , "_amaranth_shape_" ):
223
226
raise TypeError (f"EnumView type must be an enum with shape, not { enum !r} " )
224
227
try :
225
228
cast_target = Value .cast (target )
0 commit comments