fix(linter): don't flag None range on any_of/exactly_one_of slots (#3477)#3614
Open
gaoflow wants to merge 2 commits into
Open
fix(linter): don't flag None range on any_of/exactly_one_of slots (#3477)#3614gaoflow wants to merge 2 commits into
gaoflow wants to merge 2 commits into
Conversation
…nkml#3477) slot_range_as_union includes a None entry for a slot whose top-level range is unset. When the range is instead expressed through a boolean expression (any_of / exactly_one_of), no_undeclared_ranges reported the misleading "range 'None' is not defined". Drop the None entry when the union also carries concrete ranges, so genuinely undefined ranges (including those inside the expression) are still reported and a slot with no range at all is still flagged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3614 +/- ##
==========================================
+ Coverage 80.22% 83.63% +3.40%
==========================================
Files 157 157
Lines 18703 18705 +2
Branches 3945 3946 +1
==========================================
+ Hits 15004 15643 +639
+ Misses 2865 2181 -684
- Partials 834 881 +47
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
linkml-lint'sno_undeclared_rangesrule reportsrange 'None' is not definedon a slot whose range is expressed throughany_of(orexactly_one_of) instead of a top-levelrange:, even though the boolean expression fully specifies the range.Cause
SchemaView.slot_range_as_union(slot)returns the slot's own (unset) top-level range asNonealongside the concrete ranges gathered fromany_of/exactly_one_of— e.g.[None, 'integer', 'string']. The rule then checksNoneagainst the set of defined elements and flags it.Fix
Drop the
Noneentry from the range set only when the union also contains concrete ranges (i.e. when a boolean expression supplied them). This:any_of/exactly_one_ofslots,spreadsheet), now by its real name rather than asNone,default_rangeis still reported (covered bytest_missing_default_range_undeclared_ranges).Tests
Added parametrised (
any_of/exactly_one_of) tests totest_rule_no_undeclared_ranges.py: one asserting no false positive when all expression ranges are defined, one asserting an undefined expression range is still flagged by name. Red before / green after; full linter suite passes (161).Closes #3477.