streamlit/streamlit · error · ValueError
Expected an EnumMeta/Type in the second argument. Got {type(
Error message
Expected an EnumMeta/Type in the second argument. Got {type(to_enum_class)} What it means
Error "Expected an EnumMeta/Type in the second argument. Got {type(to_enum_class)}" thrown in streamlit/streamlit.
Source
Thrown at lib/streamlit/elements/lib/options_selector_utils.py:162
E1 = TypeVar("E1", bound=Enum)
E2 = TypeVar("E2", bound=Enum)
_ALLOWED_ENUM_COERCION_CONFIG_SETTINGS = ("off", "nameOnly", "nameAndValue")
def _coerce_enum(from_enum_value: E1, to_enum_class: type[E2]) -> E1 | E2:
"""Attempt to coerce an Enum value to another EnumMeta.
An Enum value of EnumMeta E1 is considered coercible to EnumType E2
if the EnumMeta __qualname__ match and the names of their members
match as well. (This is configurable in streamlist configs)
"""
if not isinstance(from_enum_value, Enum):
raise ValueError( # noqa: TRY004
f"Expected an Enum in the first argument. Got {type(from_enum_value)}"
)
if not isinstance(to_enum_class, EnumMeta):
raise ValueError( # noqa: TRY004
f"Expected an EnumMeta/Type in the second argument. Got {type(to_enum_class)}"
)
if isinstance(from_enum_value, to_enum_class):
return from_enum_value # Enum is already a member, no coercion necessary
coercion_type = config.get_option("runner.enumCoercion")
if coercion_type not in _ALLOWED_ENUM_COERCION_CONFIG_SETTINGS:
raise StreamlitValueError(
"runner.enumCoercion",
[f"'{v}'" for v in _ALLOWED_ENUM_COERCION_CONFIG_SETTINGS],
)
if coercion_type == "off":
return from_enum_value # do not attempt to coerce
# We now know this is an Enum AND the user has configured coercion enabled.
# Check if we do NOT meet the required conditions and log a failure message
# if that is the case.
from_enum_class = from_enum_value.__class__View on GitHub (pinned to 202661fc55)
When it happens
Trigger: Thrown at lib/streamlit/elements/lib/options_selector_utils.py:162 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of streamlit/streamlit@202661fc55 (2026-08-26).
Data as JSON: /api/errors/53c5b7753886fc9e.
Report an issue: GitHub.