Repository navigation
[query] fix & improve pprint for hl.Struct - #12901
Merged
Merged
Conversation
CHANGELOG: `hl.Struct` now has a correct and useful implementation of pprint. For structs with keys that were not identifiers, we produced incorrect `repr` output. For `pprint`, we just `pprint`'ed a dictionary (so you cannot even tell that the object was an `hl.Struct`). This PR: 1. Fixes `hl.Struct.__str__` to use the kwargs or dictionary representation based on whether the keys are Python identifiers. 2. Teaches `StructPrettyPrinter` to first try to `repr` the struct (this is what the default pretty printer does) 3. Teaches `StructPrettyPrinter` to properly pretty print a struct as an `hl.Struct` preferring the kwarg representation when appropriate. 4. Teaches `_same` to use pretty printing when showing differing records.
Contributor
Author
|
Lightening Tim's review load a bit. |
chrisvittal
approved these changes
Apr 27, 2023
danking
pushed a commit
to danking/hail
that referenced
this pull request
May 8, 2023
I forgot to check in the tests for hail-is#12901. I found them on my filesystem today while cleaning up untracked files.
danking
added a commit
that referenced
this pull request
May 11, 2023
I forgot to check in the tests for #12901. I found them on my filesystem today while cleaning up untracked 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.
CHANGELOG:
hl.Structnow has a correct and useful implementation of pprint.For structs with keys that were not identifiers, we produced incorrect
reproutput. Forpprint, we justpprint'ed a dictionary (so you cannot even tell that the object was anhl.Struct). This PR:hl.Struct.__str__to use the kwargs or dictionary representation based on whether the keys are Python identifiers.StructPrettyPrinterto first try toreprthe struct (this is what the default pretty printer does)StructPrettyPrinterto properly pretty print a struct as anhl.Structpreferring the kwarg representation when appropriate._sameto use pretty printing when showing differing records.