Repository navigation
#334 - Add more type annotations - #364
Merged
Merged
Conversation
- Move Sofa attribute type information from Sphinx docstring prefixes into real type annotations - Widen optional string parameters to Optional[str] in offset-mapping and sofaString APIs - Annotate the CAS sofa registry as dict[str, Sofa] and the XMI sofa attribute dict as Dict[str, Any]
- Widen Cas sofa property setters and getters to Optional[str] for sofa_string, sofa_mime, sofa_uri; fix sofa_array to return Optional[FeatureStructure] instead of str - Add ListBase, NonEmptyListBase, and NonEmptyFSListBase static type classes to model UIMA list node hierarchies with proper head/tail features - Add TYPE_NAME_LIST_BASE constant and _NON_EMPTY_PRIMITIVE_LIST_TYPES type set - Add TypeGuard functions is_list_fs, is_non_empty_list_fs, is_non_empty_fs_list for static narrowing of list node types - Wire ListBase and NonEmptyFSListBase dispatch in Type.get_class via _is_subtype_of checks on _NON_EMPTY_PRIMITIVE_LIST_TYPES - Improve XMI serialization sink parameter from IO to IO[bytes] for type clarity - Refactor _collect_list_elements to accept Optional[FeatureStructure], return List[Any], and use is_non_empty_list_fs TypeGuard instead of hasattr for list walk termination - Add Optional import to xmi.py typing imports
- Add return type annotations to all 31 pytest fixtures with -> str, and 2 fixtures returning List[FeatureStructure] - Add parameter type annotations to pytest fixture parameters in test functions (small_xmi_path, small_typesystem_xml, etc. as str) - Add parameter type annotations to @pytest.mark.parametrize arguments across test_xmi.py, test_json.py, test_typesystem.py (typesystem_xml, xmi, json_path as str; ann_begin, ann_end as int; overlap, expect_kept as bool; expect_begin, expect_end as Optional[int]; name, rangeTypeName as str; elementType, multipleReferencesAllowed as Optional[str] / Optional[bool]) - Type helper functions _make_fs_list and _fs_list_elements in test_cas.py with signatures using TypeSystem, Optional[FeatureStructure], and List[Optional[FeatureStructure]] - Refactor _fs_list_elements to use is_non_empty_list_fs() TypeGuard instead of hasattr for list node termination detection - Add typing imports (List, Optional) and cassis.typesystem imports (FeatureStructure, TypeSystem, is_non_empty_list_fs) to test files
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