diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 45a5af05..7a92c1a0 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -27,7 +27,8 @@ jobs: # install poetry #---------------------------------------------- - name: Install Poetry - run: pipx install poetry + # Pin to 1.3.2 to workaround https://github.com/python-poetry/poetry/issues/7611 + run: pipx install poetry==1.3.2 #---------------------------------------------- # check-out repo and set-up python diff --git a/linkml_runtime/utils/schemaview.py b/linkml_runtime/utils/schemaview.py index 495b36a4..d65af31c 100644 --- a/linkml_runtime/utils/schemaview.py +++ b/linkml_runtime/utils/schemaview.py @@ -1453,21 +1453,20 @@ def get_slots_by_enum(self, enum_name: ENUM_NAME = None) -> List[SlotDefinition] enum_slots.append(slot_definition) return enum_slots - def get_classes_modifying_slot(self, slot_name: SLOT_NAME = None) -> List[ClassDefinition]: + def get_classes_modifying_slot(self, slot: SlotDefinition) -> List[ClassDefinition]: """Get all ClassDefinitions that modify a given slot. :param slot_name: slot in consideration :return: list of ClassDefinitions modifying the slot of interest """ - # slot_classes = [c for c in self.all_classes().values() if c.slot_usage == slot_name] - # slot_classes = [c for c in self.all_classes().values()] - slot_classes = [] + modifying_classes = [] for class_definition in self.all_classes().values(): if class_definition.slot_usage: for slot_definition in class_definition.slot_usage.values(): - if slot_definition.name == slot_name: - slot_classes.append(class_definition) - return slot_classes + if slot_definition.name == slot.name: + modifying_classes.append(class_definition.name) + + return modifying_classes def is_slot_percent_encoded(self, slot: SlotDefinitionName) -> bool: """ diff --git a/tests/test_issues/test_linkml_issue_1126.py b/tests/test_issues/test_linkml_issue_1126.py index bb1cfb5c..fd69c1dd 100644 --- a/tests/test_issues/test_linkml_issue_1126.py +++ b/tests/test_issues/test_linkml_issue_1126.py @@ -2,7 +2,7 @@ import unittest from unittest import TestCase from linkml_runtime.utils.schemaview import SchemaView -from linkml_runtime.linkml_model import ClassDefinition +from linkml_runtime.linkml_model import ClassDefinitionName from tests.test_issues.environment import env @@ -16,13 +16,13 @@ class Issue998TestCase(TestCase): def test_issue_1126_slot_classes(self): view = SchemaView(env.input_path('linkml_issue_1126.yaml')) - slot_classes = view.get_classes_modifying_slot("type") + slot_definition = view.get_slot("type") + slot_classes = view.get_classes_modifying_slot(slot_definition) assert len(slot_classes) == 2 for element in slot_classes: - assert type(element) is ClassDefinition - assert slot_classes[0].name == "Programmer" - assert slot_classes[1].name == "Administrator" - + assert type(element) is ClassDefinitionName + assert slot_classes[0] == ClassDefinitionName("Programmer") + assert slot_classes[1] == ClassDefinitionName("Administrator") if __name__ == "__main__": unittest.main()