Skip to content

Conversation

ialarmedalien
Copy link
Collaborator

@ialarmedalien ialarmedalien commented Oct 2, 2025

Note: base branch is #454, so please review/merge that PR first.

Various minor edits to schemaview.py and the test file:

  • add in extra tests for get_element
  • updates to typing for some functions
  • update variable names for clarity

@ialarmedalien ialarmedalien self-assigned this Oct 2, 2025
@ialarmedalien ialarmedalien added enhancement New feature or request testing labels Oct 2, 2025
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.44%. Comparing base (eec9fc7) to head (ded2274).
⚠️ Report is 3 commits behind head on schemaview_add_range_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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


def _closure(f, x, reflexive: bool = True, depth_first: bool = True, **kwargs: dict[str, Any] | None) -> list: # noqa: ARG001
def _closure(
f: Callable,
Copy link
Collaborator Author

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)
Copy link
Collaborator Author

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:
Copy link
Collaborator Author

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

Comment on lines +1719 to +1720
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.
Copy link
Collaborator Author

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)
Copy link
Collaborator Author

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.

Comment on lines +1850 to +1851
attr_name = attr
real_a_value = a_value
Copy link
Collaborator Author

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

Comment on lines +904 to +906
# 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)
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

@kevinschaper kevinschaper merged commit 868a5a1 into schemaview_add_range_tests Oct 3, 2025
17 checks passed
@amc-corey-cox amc-corey-cox deleted the schemaview_misc_edits branch October 20, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants