From 54b13ffabefb7ac13c451228194e7a56b769ca01 Mon Sep 17 00:00:00 2001 From: Jeongyeob Hong Date: Tue, 3 Feb 2026 15:48:06 -0800 Subject: [PATCH] additional safety condition for terminal rules --- src/ultk/language/grammar/grammar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ultk/language/grammar/grammar.py b/src/ultk/language/grammar/grammar.py index 6cf46da..7be0ab8 100644 --- a/src/ultk/language/grammar/grammar.py +++ b/src/ultk/language/grammar/grammar.py @@ -98,9 +98,9 @@ def _and(p1: bool, p2: bool) -> bool: # parameters = {'name': Parameter} ordereddict, so we want the values # each value is a Paramter, with .annotation being the actual annotation rhs: tuple[Any, ...] | None = tuple(arg.annotation for arg in args.values()) - # if one type annotation, a type of Referent, treat this as a terminal, no children = None RHS + # if one type annotation is class, a type of Referent, treat this as a terminal, no children = None RHS # TODO: make this more general? - if rhs and len(rhs) == 1 and issubclass(rhs[0], Referent): + if rhs and len(rhs) == 1 and inspect.isclass(rhs[0]) and issubclass(rhs[0], Referent): rhs = None return cls( name=rule_name,