From 4cc1a047ee1b206e9dcd9b5237472edaf805480d Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 13 Mar 2026 17:15:11 -0400 Subject: [PATCH 1/3] Make order of notes consistent --- src/pydantic2linkml/gen_linkml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pydantic2linkml/gen_linkml.py b/src/pydantic2linkml/gen_linkml.py index d6865094..cf9fb133 100644 --- a/src/pydantic2linkml/gen_linkml.py +++ b/src/pydantic2linkml/gen_linkml.py @@ -367,7 +367,7 @@ def attach_note(note: str) -> None: mixins=mixins, slots=slots, slot_usage=slot_usage, - notes=notes, + notes=sorted(notes), ) def _establish_supporting_defs(self) -> None: From 8c9e1f43fac6116121254ec1dd992e99565829f2 Mon Sep 17 00:00:00 2001 From: Isaac To Date: Mon, 16 Mar 2026 17:52:27 -0700 Subject: [PATCH 2/3] feat: Sort notes in slot definition for consistent order This allows the produced LinkML schema to have notes in slots to be in a consistent order --- src/pydantic2linkml/gen_linkml.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pydantic2linkml/gen_linkml.py b/src/pydantic2linkml/gen_linkml.py index cf9fb133..21c72111 100644 --- a/src/pydantic2linkml/gen_linkml.py +++ b/src/pydantic2linkml/gen_linkml.py @@ -448,6 +448,10 @@ def generate(self) -> SlotDefinition: # Shape the contained slot according to core schema of the corresponding field self._shape_slot(self._field_schema.schema) + # Ensure the notes in the slot definition are sorted in a consistent order + assert isinstance(self._slot.notes, list) + self._slot.notes.sort() + self._used = True return self._slot From b070ef9a01ae49cc87d8474d4e66157c802a3f6f Mon Sep 17 00:00:00 2001 From: Isaac To Date: Mon, 16 Mar 2026 18:05:42 -0700 Subject: [PATCH 3/3] perf: perform sorting of class notes in place This avoids creating a new list --- src/pydantic2linkml/gen_linkml.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pydantic2linkml/gen_linkml.py b/src/pydantic2linkml/gen_linkml.py index 21c72111..a650d51f 100644 --- a/src/pydantic2linkml/gen_linkml.py +++ b/src/pydantic2linkml/gen_linkml.py @@ -358,6 +358,9 @@ def attach_note(note: str) -> None: slots.sort(key=str.casefold) slot_usage.sort(key=lambda s: s.name.casefold()) + # Ensure notes are sorted in a consistent order + notes.sort() + return ClassDefinition( model.__name__, description=( @@ -367,7 +370,7 @@ def attach_note(note: str) -> None: mixins=mixins, slots=slots, slot_usage=slot_usage, - notes=sorted(notes), + notes=notes, ) def _establish_supporting_defs(self) -> None: