Skip to content

Commit

Permalink
Enable passing pre-defined OBO Literal
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Jan 17, 2025
1 parent 07102e4 commit 889d73d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pyobo/struct/struct_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,19 @@ def append_property(
def annotate_literal(
self,
prop: ReferenceHint,
value: str,
value: str | OBOLiteral,
datatype: Reference | None = None,
*,
annotations: Iterable[Annotation] | None = None,
) -> Self:
"""Append an object annotation."""
prop = _ensure_ref(prop)
literal = OBOLiteral(value, datatype or v.xsd_string)
if isinstance(value, str):
literal = OBOLiteral(value, datatype or v.xsd_string)
elif datatype is not None:
raise ValueError("can not pass pre-instantiated literal with a datatype")
else: # the value is a pre-instantiated OBOLiteral
literal = value
self.properties[prop].append(literal)
self._extend_annotations(prop, literal, annotations)
return self
Expand Down

0 comments on commit 889d73d

Please sign in to comment.