Skip to content

Commit aaa3c76

Browse files
committed
Fix ChoiceItem init with default=FirstChoice (TypeError: issubclass() arg 1 must be a class)
1 parent 127237a commit aaa3c76

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

guidata/dataset/dataitems.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
import datetime
9696
import os
9797
import re
98-
from collections.abc import Callable
98+
from collections.abc import Callable, Sequence
9999
from enum import Enum, EnumMeta
100100
from typing import TYPE_CHECKING, Any, Generic, Iterable, TypeVar
101101

@@ -957,8 +957,10 @@ def __init__(
957957
_choices_data = []
958958
for idx, choice in enumerate(choices):
959959
_choices_data.append(self._normalize_choice(idx, choice))
960-
if default is FirstChoice and (
961-
not isinstance(choices, Callable) or issubclass(choices, Enum)
960+
if (
961+
default is FirstChoice
962+
and isinstance(_choices_data, Sequence)
963+
and isinstance(_choices_data[0], Sequence)
962964
):
963965
default = _choices_data[0][0]
964966
elif default is FirstChoice:

0 commit comments

Comments
 (0)