#359 - Introduce AnnotationBase static type carrying the sofa feature - #360
Merged
reckart merged 1 commit intoJul 8, 2026
Conversation
- Introduce AnnotationBase static type as intermediate base between FeatureStructure and Annotation, carrying the sofa feature - Re-parent Annotation onto AnnotationBase to mirror UIMA's type hierarchy (uima.cas.AnnotationBase → uima.tcas.Annotation) - Add is_annotation_base() TypeGuard alongside is_annotation() for type narrowing - Generalize FS-class builder from 2-way to 3-way base selection, skipping re-declaration of inherited features (sofa for AnnotationBase; sofa/begin/end for Annotation) - Add TYPE_CHECKING import of Sofa to avoid circular import; use cast() at sofa access sites to satisfy static type checker while preserving hasattr() runtime guards
There was a problem hiding this comment.
Pull request overview
This PR introduces an AnnotationBase intermediate base class (between FeatureStructure and Annotation) to better mirror UIMA’s hierarchy and to provide a nominal/static home for the sofa feature across all uima.cas.AnnotationBase subtypes.
Changes:
- Add
AnnotationBaseandis_annotation_base()and re-parentAnnotationto inherit fromAnnotationBase. - Generalize FS class generation to select among
FeatureStructure/AnnotationBase/Annotationand avoid redeclaring inherited features (sofa,begin,end). - Update CAS/JSON/util code paths to access
sofavia the new base and use casts for static type checking; adjust a test string constant.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_cas.py | Updates the test’s sofa_uri string value. |
| src/cassis/util.py | Adjusts comparable-text anchor generation to access sofa via AnnotationBase (with casts). |
| src/cassis/typesystem.py | Introduces AnnotationBase, re-parents Annotation, adds is_annotation_base, and updates FS class base selection logic. |
| src/cassis/json.py | Updates offset-fixup logic to treat sofa as coming from AnnotationBase (with casts). |
| src/cassis/cas.py | Updates CAS add() to assign sofa via AnnotationBase (cast for typing). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
reckart
deleted the
refactoring/359-Introduce-AnnotationBase-static-type-carrying-the-sofa-feature
branch
July 8, 2026 20:22
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.
What's in the PR
How to test manually
Automatic testing
Documentation