-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add inheritance ordering, unify element ordering #313
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #313 +/- ##
==========================================
- Coverage 62.92% 62.84% -0.09%
==========================================
Files 62 63 +1
Lines 8532 8580 +48
Branches 2436 2444 +8
==========================================
+ Hits 5369 5392 +23
- Misses 2553 2576 +23
- Partials 610 612 +2 ☔ View full report in Codecov by Sentry. |
@@ -342,6 +370,32 @@ def _order_rank(self, elements: dict): | |||
rank_ordered_elements.update(unranked_map) | |||
return rank_ordered_elements | |||
|
|||
def _order_inheritance(self, elements: DefDict) -> DefDict: | |||
""" | |||
sort classes such that if C is a child of P then C appears after P in the list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick nit: it's not just classes, inheritance can be applied to slots and subsets as well, so this is for elements generally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally - I was just copying the existing comment there. Specifically the type bound is for Definitions since you need the is_a
property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the ability to order elements by inheritance @sneakers-the-rat we might want to use this functionality in the documentation generator at some point as well!
The code changes look good to me, this PR is ready to go 🚀
Schemaview seems like the right place to keep sorting methods that will be used by all the generators. Lo and behold, it already is!
Added the inheritance ordering method used by pythongen and pydanticgen, put all ordering into a single method.
Must be merged before the adjoining linkml PR (will add link in a second) and linkml lockfile must be regenerated to reflect the release containing this PR