Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the Struct.pformat() method to hide private fields (those starting with _) from pretty-printed output, making struct representations cleaner and avoiding potential errors when accessing private properties.
Changes:
- Add filtering to skip private fields (starting with
_) initer_struct_ppfmt_lines() - Refactor control flow from nested
iftoif/elif/elsestructure for clearer logic - Move
yieldstatement inside theelseblock to ensure it only outputs non-private, non-nested fields
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
Author
|
Hmm question is should we make a (unit) test for this? |
Skip fields starting with `_` in pretty-printed struct output to avoid cluttering displays with internal/private state (and/or accessing private properties which have errors Bp). Deats, - add `if k[0] == '_': continue` check to skip private fields - change nested `if isinstance(v, Struct)` to `elif` since we now have early-continue for private fields - mv `else:` comment to clarify it handles top-level fields - fix indentation of `yield` statement to only output non-private, non-nested fields (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code
dd86083 to
f76e822
Compare
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.
Skip fields starting with
_in pretty-printed struct output toavoid cluttering console with internal/private state (and/or
accessing private properties which raise errors.
Impl deats,
if k[0] == '_': continuecheck to skip private fieldsif isinstance(v, Struct)toelifsince we nowhave early-continue for private fields
else:comment to clarify it handles top-level fieldsyieldstatement to only output non-private,non-nested fields
Pre-merge todo
repr()output.