Skip to content

fix(linter): don't flag None range on any_of/exactly_one_of slots (#3477)#3614

Open
gaoflow wants to merge 2 commits into
linkml:mainfrom
gaoflow:fix/3477-no-undeclared-ranges-any-of
Open

fix(linter): don't flag None range on any_of/exactly_one_of slots (#3477)#3614
gaoflow wants to merge 2 commits into
linkml:mainfrom
gaoflow:fix/3477-no-undeclared-ranges-any-of

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 7, 2026

Copy link
Copy Markdown

Problem

linkml-lint's no_undeclared_ranges rule reports range 'None' is not defined on a slot whose range is expressed through any_of (or exactly_one_of) instead of a top-level range:, even though the boolean expression fully specifies the range.

classes:
  Foo:
    attributes:
      bar:
        any_of:
          - range: integer
          - range: string
$ linkml-lint test.yaml
  error    Class 'Foo' slot 'bar' range 'None' is not defined.  (no_undeclared_ranges)

Cause

SchemaView.slot_range_as_union(slot) returns the slot's own (unset) top-level range as None alongside the concrete ranges gathered from any_of/exactly_one_of — e.g. [None, 'integer', 'string']. The rule then checks None against the set of defined elements and flags it.

Fix

Drop the None entry from the range set only when the union also contains concrete ranges (i.e. when a boolean expression supplied them). This:

  • removes the false positive for any_of/exactly_one_of slots,
  • keeps flagging a genuinely undefined range named inside the expression (e.g. spreadsheet), now by its real name rather than as None,
  • preserves the existing behaviour that a slot with no range at all and no default_range is still reported (covered by test_missing_default_range_undeclared_ranges).

Tests

Added parametrised (any_of/exactly_one_of) tests to test_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.

gaoflow and others added 2 commits June 7, 2026 22:21
…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

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.63%. Comparing base (08d487a) to head (f0b27f5).
⚠️ Report is 1 commits behind head on main.

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     
Flag Coverage Δ
linkml 80.21% <100.00%> (+<0.01%) ⬆️
runtime 80.17% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linkml-lint no_undeclared_ranges false-positives on slots with any_of declarations

3 participants