Repository navigation
Include inherited fields in slotted dataclass formatting - #181
Open
rupayon123 wants to merge 2 commits into
Open
rupayon123 wants to merge 2 commits into
rupayon123 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
This branch has not been deployed
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.
Formatting a fully slotted dataclass subclass only enumerates its leaf
__slots__, so inherited dataclass fields disappear. A child with no new slots can print as empty despite holding inherited values.Add missing dataclass field names to the existing no-
__dict__fallback, then retain the leaf slots in their original order. This preserves manually declared auxiliary slots, explicit weakref slots and existing ordering; string-form slot metadata is treated as one name. Classes with an instance__dict__keep their current behavior. Genuinely absent slot attributes are omitted, so inheritedfield(init=False, repr=False)values are safe before assignment. Assigned values, including the formatter’s ownMISSINGobject, remain visible.Validation on CPython 3.13.14 / macOS arm64:
Other supported runtime/OS combinations remain unverified locally. This only changes the existing fully slotted fallback; it does not add previously hidden inherited non-field auxiliary slots.
Summary by cubic
Fixes formatting of fully slotted dataclass subclasses so inherited fields no longer disappear from
pformat()output.Bug Fixes
__slots__to the no-__dict__fallback, matching dataclass field ordering.AttributeError.__dict__keep their current behavior.Written for commit 40698a1. Summary will update on new commits.