-
Notifications
You must be signed in to change notification settings - Fork 23
#336 - Introduce Annotation class #337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a concrete Annotation base class with default begin=0 and end=0 attributes to provide a stable typing foundation for annotation instances. This addresses sorting and serialization issues with runtime-generated annotation types.
- Introduced
Annotationclass that all annotation types inherit from - Updated XMI test fixtures to include default
begin="0" end="0"attributes for annotation-like types - Refactored sorting logic to use stable key-based comparisons instead of comparator functions
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| cassis/typesystem.py | Added Annotation base class and updated type generation to inherit from it for annotation types |
| cassis/cas.py | Updated type hints to use Annotation instead of FeatureStructure where appropriate; improved duck-typing in _sort_func |
| cassis/xmi.py | Fixed offset conversion logic with defensive checks and improved comments |
| cassis/util.py | Replaced comparator-based sorting with stable key functions; refactored hash computation to return deterministic string representations |
| tests/test_files/xmi/*.xmi | Added begin="0" end="0" attributes to annotation instances in test fixtures |
| tests/test_ducktyping.py | New test file verifying runtime-generated annotations work correctly |
| tests/test_cas.py | Added tests for non-annotation feature structures and runtime-generated annotations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
121e10f to
9318f26
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Should be possible to get away with not sorting here assuming that all_features returns the features always in | ||
| # the same order | ||
| parts: list[str] = [] |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent type hint syntax. The file imports Dict and Any from typing (line 4) but uses the built-in list[str] syntax here instead of List[str] from typing. For consistency with the rest of the file and better compatibility, either add List to the imports and use List[str], or update all type hints to use PEP 585 built-in generics throughout the file.
cassis/util.py
Outdated
| return "|".join(parts) | ||
|
|
||
|
|
||
| def _normalize_feature_value(value: Any): |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_normalize_feature_value returns tuple of size 1 and tuple of size 2.
_normalize_feature_value returns tuple of size 1 and tuple of size 4.
_normalize_feature_value returns tuple of size 1 and tuple of size 2.
_normalize_feature_value returns tuple of size 1 and tuple of size 2.
_normalize_feature_value returns tuple of size 2 and tuple of size 4.
_normalize_feature_value returns tuple of size 2 and tuple of size 4.
_normalize_feature_value returns tuple of size 2 and tuple of size 4.
- Introduced Annotation class with default begin/end 0 - Update reference data accordingly - Fixed several issues with sorting/ordering annotations
9318f26 to
e5eb8e0
Compare
What's in the PR
How to test manually
Automatic testing
Documentation