Skip to content

Commit aea0ab4

Browse files
authored
fix: use the origin type when validating a grammar list (#82)
issubclass working on a GenericAlias was a bug that was fixed in python 3.13 (see python/cpython#101162) Fixes #81 Signed-off-by: Paul Mars <paul.mars@canonical.com>
1 parent 869adcc commit aea0ab4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

craft_grammar/models.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def _validate_grammar_list( # noqa: PLR0912
7474
) -> list[T]:
7575
# Check if the type_ is supposed to be a list
7676
sub_type: Any = get_args(type_)
77+
unsubscripted_type = get_origin(type_) or type_
7778

7879
# handle typed list
7980
if sub_type:
@@ -121,7 +122,7 @@ def _validate_grammar_list( # noqa: PLR0912
121122
pass
122123
else:
123124
continue
124-
if issubclass(type_, str):
125+
if issubclass(unsubscripted_type, str):
125126
if isinstance(item, dict):
126127
errors.append(
127128
pydantic_core.InitErrorDetails(

0 commit comments

Comments
 (0)