Repository navigation
Validate inlined objects as the class their designates_type names - #177
Conversation
An inlined object in a slot whose range is an abstract class was validated as that range, so slots defined only on the subclass it names (e.g. references) were skipped and validation passed having checked nothing. _validate_instance now resolves the concrete class through the range's type designator slot (own or inherited) before anything else, accepting a class name, CURIE or URI, and only a descendant of the declared range. Resolving there covers single objects, list items, keyed mappings and the top-level target class alike. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude finished @caufieldjh's task in 1m 0s —— View job Code review: designates_type resolution (#170)
I couldn't run the test suite because Overall: looks good to merge. The fix is small and placed well. The tests cover the realistic cases. I found no correctness bugs and only have a few minor suggestions. What works well
Suggestions (all minor)
SecurityNo concerns. The data can't widen its declared range, and no new I/O is added. Test coverageCoverage is good. There are 14 tests built on the schema from the issue, covering single, list and keyed shapes, a grandchild class, CURIE and URI values, fallbacks, the top-level class and the CLI. The helper's doctest also documents the behaviour. You note that 10 of the 14 failed before the fix. |
Falling back silently to the declared range on an unknown or unrelated designates_type value (e.g. a typo) brought back the #170 symptom: a passing run that checked none of the subclass's slots. The fallback now yields a WARN result naming the value and the range, so the run fails. Also document that class names, CURIEs and URIs are all accepted whatever the designator's range, deliberately. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude finished @caufieldjh's task in 59s —— View job Re-review after
|
Closes #170.
Problem
When a slot's range is an abstract class and the inlined object names its concrete subclass through a
designates_typeslot, the plugin validated the object as the abstract range. Slots defined only on the subclass (e.g.references) were filtered out, so their titles and excerpts were never checked and validation reported success ("Titles checked: 0").Fix
_validate_instancenow calls a new_resolve_concrete_classbefore anything else. Resolving in that one place covers every route into it: nested single objects, each list item independently, each value of a keyed mapping (inlined_as_list: false), and the top-level--target-class.The helper:
Tests
tests/test_designates_type.py(14 tests) uses the schema from #170 and covers nested single objects, mixed-type lists, keyed mappings, a grandchild type, CURIE and URI values, fallback for unknown or unrelated values, the top-level target class, the helper directly, and the CLI reproduction (Titles checked: 1, exit 1). 10 of the 14 failed before the fix; the 4 fallback cases already passed. The helper also has doctests.just test: 2594 passed, 6 failed, all network tests intest_pmid_network.py/test_html_fulltext_acceptance.py. Rerunning them on a cleanmainalso fails, with a different set each run and NCBI timeouts in the log. mypy and ruff pass.🤖 Generated with Claude Code