{"record":{"id":"53c5b7753886fc9e","repo":"streamlit/streamlit","slug":"expected-an-enummeta-type-in-the-second-argument","errorCode":null,"errorMessage":"Expected an EnumMeta/Type in the second argument. Got {type(to_enum_class)}","messagePattern":"Expected an EnumMeta/Type in the second argument\\. Got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/streamlit/elements/lib/options_selector_utils.py","lineNumber":162,"sourceCode":"E1 = TypeVar(\"E1\", bound=Enum)\nE2 = TypeVar(\"E2\", bound=Enum)\n\n_ALLOWED_ENUM_COERCION_CONFIG_SETTINGS = (\"off\", \"nameOnly\", \"nameAndValue\")\n\n\ndef _coerce_enum(from_enum_value: E1, to_enum_class: type[E2]) -> E1 | E2:\n    \"\"\"Attempt to coerce an Enum value to another EnumMeta.\n\n    An Enum value of EnumMeta E1 is considered coercible to EnumType E2\n    if the EnumMeta __qualname__ match and the names of their members\n    match as well. (This is configurable in streamlist configs)\n    \"\"\"\n    if not isinstance(from_enum_value, Enum):\n        raise ValueError(  # noqa: TRY004\n            f\"Expected an Enum in the first argument. Got {type(from_enum_value)}\"\n        )\n    if not isinstance(to_enum_class, EnumMeta):\n        raise ValueError(  # noqa: TRY004\n            f\"Expected an EnumMeta/Type in the second argument. Got {type(to_enum_class)}\"\n        )\n    if isinstance(from_enum_value, to_enum_class):\n        return from_enum_value  # Enum is already a member, no coercion necessary\n\n    coercion_type = config.get_option(\"runner.enumCoercion\")\n    if coercion_type not in _ALLOWED_ENUM_COERCION_CONFIG_SETTINGS:\n        raise StreamlitValueError(\n            \"runner.enumCoercion\",\n            [f\"'{v}'\" for v in _ALLOWED_ENUM_COERCION_CONFIG_SETTINGS],\n        )\n    if coercion_type == \"off\":\n        return from_enum_value  # do not attempt to coerce\n\n    # We now know this is an Enum AND the user has configured coercion enabled.\n    # Check if we do NOT meet the required conditions and log a failure message\n    # if that is the case.\n    from_enum_class = from_enum_value.__class__","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/streamlit/streamlit/blob/202661fc552db98c2ba0bb0e113d619689baf9de/lib/streamlit/elements/lib/options_selector_utils.py#L144-L180","documentation":"Error \"Expected an EnumMeta/Type in the second argument. Got {type(to_enum_class)}\" thrown in streamlit/streamlit.","triggerScenarios":"Thrown at lib/streamlit/elements/lib/options_selector_utils.py:162 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"202661fc552db98c2ba0bb0e113d619689baf9de","analyzedAt":"2026-08-26T09:13:21.291Z","schemaVersion":2},"datasetVersion":"2026-08-26T14:46:13.012Z"}