Skip to content

Commit

Permalink
Bundle slots into a list if use_attributes is True
Browse files Browse the repository at this point in the history
In this way, the slot definition in `slots` can be added
to the class as an attribute, better than raising an
exception
  • Loading branch information
candleindark committed Sep 29, 2024
1 parent ba0a94f commit e2256f1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions linkml_runtime/utils/schema_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def add_class(
:param cls: name, dict object, or ClassDefinition object to add
:param slots: slot of slot names or slot objects.
Note: If `use_attributes=True`, then this must be a list of SlotDefinitions
:param slot_usage: slots keyed by slot name
:param replace_if_present: if True, replace existing class if present
:param kwargs: additional ClassDefinition properties
Expand All @@ -82,9 +81,7 @@ def add_class(
self.schema.classes[cls.name] = cls
if use_attributes:
if not isinstance(slots, list):
raise ValueError(
"If `use_attributes=True`, then `slots` must be a list."
)
slots = [slots]
for s in slots:
if isinstance(s, SlotDefinition):
cls.attributes[s.name] = s
Expand Down

0 comments on commit e2256f1

Please sign in to comment.