-
Notifications
You must be signed in to change notification settings - Fork 35
schemaview.py - misc minor edits #463
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
schemaview.py - misc minor edits #463
Conversation
…riables for clarity
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## schemaview_add_range_tests #463 +/- ##
==============================================================
- Coverage 77.48% 77.44% -0.05%
==============================================================
Files 52 52
Lines 4478 4470 -8
Branches 979 975 -4
==============================================================
- Hits 3470 3462 -8
Misses 782 782
Partials 226 226 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
||
def _closure(f, x, reflexive: bool = True, depth_first: bool = True, **kwargs: dict[str, Any] | None) -> list: # noqa: ARG001 | ||
def _closure( | ||
f: Callable, |
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.
Adding this type annotation reformatted the whole line
def element_by_schema_map(self) -> dict[ElementName, SchemaDefinitionName]: | ||
ix = {} | ||
schemas = self.all_schema(True) | ||
schemas = self.all_schema(imports=True) |
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.
just for clarity
|
||
@lru_cache(None) | ||
def get_class(self, class_name: CLASS_NAME, imports: bool = True, strict: bool = False) -> ClassDefinition: | ||
def get_class(self, class_name: CLASS_NAME, imports: bool = True, strict: bool = False) -> ClassDefinition | None: |
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.
These methods can all return None
Typically any given slot has exactly one range, and one metamodel element type. | ||
Starting at LinkML 1.2, ranges can be defined as unions of multiple types. |
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.
linkml 1.2 is in the far distant past now!
u = SchemaUsage(used_by=cn, slot=sn, metaslot=k, used=x) | ||
u.inferred = sn in direct_slots | ||
ix[x].append(u) | ||
slot = self.induced_slot(sn, cn) |
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.
Renamed these variables whilst I was trying to work out how this method worked. Created a couple of new variables to prevent linter complaints about editing an iterator during looping.
attr_name = attr | ||
real_a_value = a_value |
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.
create new variables for these values rather than editing the loop iterator
# N.b. this may fail in schemas where there are different types | ||
# of element with the same name | ||
assert e == creature_view.get_element(entity_name) |
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.
add in tests of the get_element
function
{"RangeEnum", "RangeClass", "string"}, | ||
{CD, ED, TD}, | ||
], | ||
# invalid - can't have both any_of and exactly_one_of |
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.
some extra docs about these combinations
Note: base branch is #454, so please review/merge that PR first.
Various minor edits to schemaview.py and the test file:
get_element