Fix docs: non-string annotations are converted, not rejected#85
Open
Builder106 wants to merge 1 commit into
Open
Fix docs: non-string annotations are converted, not rejected#85Builder106 wants to merge 1 commit into
Builder106 wants to merge 1 commit into
Conversation
The docstrings in dag.py, the exception table in docs/api.md, and the usage_patterns notebook all stated that `set_annotations=True` requires string annotations and raises `NonStringAnnotationError` otherwise. This has been inaccurate since OpenSourceEconomics#67 ("do not require string annotations from users"): non-string annotations are converted to their string representation via `ensure_annotations_are_strings`, and `NonStringAnnotationError` is never raised anywhere in the code base (nor is it exported or covered by tests). - Update the stale docstrings (FunctionExecutionInfo, concatenate_functions, _create_combined_function_from_dag, _create_concatenated_function, create_execution_info) to describe the actual convert behavior and drop the false `NonStringAnnotationError` Raises entries. - Update the docs/api.md exception table and the usage_patterns notebook. - Add a regression test asserting that concatenate_functions(set_annotations= True) converts non-string annotations instead of raising.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
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.
Problem
Several docstrings and docs claim that
set_annotations=Truerequires string annotations and raisesNonStringAnnotationErrorwhen they are not strings. For example,concatenate_functions:This has been inaccurate since #67 ("do not require string annotations from users"). The current behavior is to convert non-string annotations to their string representation (via
ensure_annotations_are_strings→_get_str_repr). In fact,NonStringAnnotationErroris never raised anywhere in the source, is not exported from the package, and has no tests:Changes
dag.py(FunctionExecutionInfo,concatenate_functions,_create_combined_function_from_dag,_create_concatenated_function,create_execution_info) to describe the actual convert behavior and removed the falseNonStringAnnotationErrorRaises:entries.docs/api.mdand theset_annotationsnote indocs/usage_patterns.ipynb.tests/test_without_string_annotations.pyasserting thatconcatenate_functions(..., set_annotations=True)converts non-string annotations rather than raising.Verification
pytest: 195 passedruff check/ruff format --check: cleanty check: cleanOne question for maintainers
NonStringAnnotationErroris now effectively orphaned — defined indags/exceptions.pybut never raised, not exported, and untested. I left the class in place so this PR stays documentation-only and doesn't change the (informal) exception surface. Happy to either remove it in this PR or open a follow-up if you'd prefer to deprecate/drop it.