def __init__(self, enum, target):
        """Constructs a view with the given enum type and target
        (a :ref:`value-like <lang-valuelike>`).
        """
        if not isinstance(enum, EnumType) or not hasattr(enum, "_amaranth_shape_"):
            raise TypeError(f"EnumView type must be an enum with shape, not {enum!r}")
        try:
            cast_target = Value.cast(target)
        except TypeError as e:
            raise TypeError("EnumView target must be a value-castable object, not {!r}"
                            .format(target)) from e
        if cast_target.shape() != enum.as_shape():
            raise TypeError("EnumView target must have the same shape as the enum")
        self.__enum = enum
        self.__target = cast_target
Constructs a view with the given enum type and target
        (a :ref:`value-like <lang-valuelike>`).
        
amaranth/lib/enum.py