fix: register java.util.HashSet in OWLAPIMapper to fix get_punned_iris() - #280
Merged
Merged
Conversation
getPunnedIRIs() returns a concrete java.util.HashSet whenever the ontology has at least one punned IRI. OWLAPIMapper.map_() had no exact registration for it, so functools.singledispatch fell back to MRO-based dispatch over JPype's dynamic Java-class proxies, which raised "RuntimeError: Inconsistent hierarchy" -- the same failure mode LinkedHashSet was already patched for. Register HashSet the same way. Fixes #278 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #280 +/- ##
===========================================
+ Coverage 83.34% 83.44% +0.09%
===========================================
Files 67 67
Lines 12408 12521 +113
===========================================
+ Hits 10342 10448 +106
- Misses 2066 2073 +7
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.
Summary
SyncOntology.get_punned_iris()raisedRuntimeError: Inconsistent hierarchywhenever the ontology actually contained a punned IRI.getPunnedIRIs()returns a concretejava.util.HashSetwhen non-empty.OWLAPIMapper.map_()(afunctools.singledispatchmethod) had no exact registration forHashSet, so it fell back to MRO-based dispatch over JPype's dynamically-generated Java class proxies, which can't always produce a consistent C3 linearization — hence the crash. This is the same failure modeLinkedHashSetwas already patched for previously.HashSetdirectly alongside the existingLinkedHashSet/ArrayList/List/Setregistrations, sosingledispatchhits its exact-type fast path instead of the MRO resolver.Test plan
test_get_punned_iris_with_punningintests/test_sync_ontology.py, reproducing the issue's punning scenario (verified it fails with the pre-fix code and passes with the fix)ruff check owlapy --line-length=200passestests/test_sync_ontology.py,tests/test_owlapi_mapper.py,tests/test_owlapy_ontology_management.pyall pass (39 passed)CHANGELOG.md's[Unreleased]section🤖 Generated with Claude Code