-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: preserve list meanings #575
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
20e851b
prefer top-level meanings for list protos
daniel-sanche 930000e
all empty shouyld return None
daniel-sanche 76638b3
fixed test
daniel-sanche 095dcec
added tests
daniel-sanche 8b6f9d8
support both root meaning, and sub-value meanings
daniel-sanche 4a28ea2
avoid unneeded recursion
daniel-sanche a8b8c65
added new end to end test
daniel-sanche c636d46
fixed lint
daniel-sanche e420263
clarify that None means no changes
daniel-sanche 0feba13
to fix system tests, return None if no meaning or submeanings
daniel-sanche ae98060
fixed lint
daniel-sanche b2caf3b
Merge branch 'main' into preserve_list_meanings
daniel-sanche f8024bc
small refactor
daniel-sanche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, why wouldn't we just return a tuple of (None, []), instead of transforming the return type here to just a single None?
(To me it would be simpler to have a guaranteed format for List, and a guaranteed format for non-lists, or maybe this saves some RAM?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case it's not clear: the reason for this transformation is to flatten giant lists of
[None, None, None, ...]
, so we don't have to iterate over the whole thing again later, when there are no meanings present (which is probably the most common situation)You're right that we could return an empty list instead of None here to signal that there are no meanings present. But it's a trade-off. That would buy us type consistency, but then we'd lose the property that the sub-meaning list is always be the same size as the original array. We'd need to remember to do size comparisons before iterating, so we don't really win anything from that change. And size mismatches wouldn't be flagged by type checkers like missing None checks, so those bugs would be harder to notice.
TL;DR: This is a special case in our processing logic, and it's usually safer to use None to signal special cases, instead of returning lists with unpredictable sizes