Add Typing to getTextWithFields#12969
Merged
Merged
Conversation
TextWithFieldsT is List[Union[str, FieldCommand]] getTextWithFields returns the result directly and has type annotation declaring it returns TextWithFieldsT. Other usages of _getFieldsInRange seem to filter out None, although it is hard to be conclusive about this.
Note that XMLTextParser().parse returns List[Union[FieldCommand, Optional[str]]] TextInfo.TextWithFieldsT is str not optional: List[Union[str, FieldCommand]]
michaelDCurran
requested changes
Nov 23, 2021
michaelDCurran
left a comment
Member
There was a problem hiding this comment.
Other than the extra list, I'm happy with all of this.
michaelDCurran
approved these changes
Nov 24, 2021
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.
Link to issue number:
Noticed during investigation of #12919
Summary of the issue:
getTextWithFieldsis expected to returnTextWithFieldsTwhich is aList[Union[str, FieldCommand]]Many of the overrides of
getTextWithFieldsdidn't specify the type, thus did not benefit from type hinting, some of themreturn incorrect types.
Description of how this pull request fixes the issue:
getTextWithFields_getFieldsInRangeis used, it must returnTextWithFieldsT_getFieldsInRangeeasier to read, break out the normalization of commands.Note
_getFieldsInRangewas in one case returning an empty string, not a list with an empty string, this has been resolved.Testing strategy:
Test early on alpha.
Known issues with pull request:
The
_getFieldsInRangeempty string may have been treated as an empty iterable, in which case the more correct modification would be to return an empty list.Change log entries:
None
Code Review Checklist: