ENH: tdb: ParseException returns correct line numbers#550
Merged
richardotis merged 5 commits intopycalphad:developfrom Aug 2, 2024
Merged
ENH: tdb: ParseException returns correct line numbers#550richardotis merged 5 commits intopycalphad:developfrom
richardotis merged 5 commits intopycalphad:developfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #550 +/- ##
===========================================
+ Coverage 91.74% 91.77% +0.02%
===========================================
Files 77 77
Lines 11981 11996 +15
===========================================
+ Hits 10992 11009 +17
+ Misses 989 987 -2 ☔ View full report in Codecov by Sentry. |
bocklund
approved these changes
Aug 2, 2024
Collaborator
bocklund
left a comment
There was a problem hiding this comment.
Looks great! Appears to be performance neutral for successful read times when tested against a large dataset of databases and a really nice quality of life improvement.
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.
In the TDB parser, the pyparsing grammar only sees one command-delimited (
!-delimited) line at a time. In the event of a parser exception, the error reporting metadata incorrectly returns a line number of 1.This PR modifies the
ParseExceptionobject raised by the parser to refer to the (almost) original input text. We also take the opportunity to shorten the error message returned by the string representation of the object. To ensure the column number printed in the error message aligns with the input text, we remove some pre-processing of the text where whitespace was stripped (the pyparsing grammar for TDB already skips whitespace).Example
Current Behavior (
develop)New Behavior
Note for this example we might say that returning an error at the end of line 3 would be more intuitive for the user, and that would be correct; for this case the parser cannot distinguish between a missing command delimiter and a reference key designation until encountering the
Gcharacter (after the space) in the next full line. If we improve the grammar to distinguish these cases, the error message will automatically become more useful.