diff --git a/libyang/schema.py b/libyang/schema.py index f7fda21..d3f5465 100644 --- a/libyang/schema.py +++ b/libyang/schema.py @@ -1568,7 +1568,11 @@ def units(self) -> Optional[str]: return c2str(self.cdata_leaf.units) def type(self) -> Type: - return Type(self.context, self.cdata_leaf.type, self.cdata_leaf_parsed.type) + return Type( + self.context, + self.cdata_leaf.type, + self.cdata_leaf_parsed.type if self.cdata_leaf_parsed else None, + ) def is_key(self) -> bool: if self.cdata_leaf.flags & lib.LYS_KEY: @@ -1600,7 +1604,9 @@ def units(self) -> Optional[str]: def type(self) -> Type: return Type( - self.context, self.cdata_leaflist.type, self.cdata_leaflist_parsed.type + self.context, + self.cdata_leaflist.type, + self.cdata_leaflist_parsed.type if self.cdata_leaflist_parsed else None, ) def defaults(self) -> Iterator[Union[None, bool, int, str, float]]: