Repository navigation
Fix tuple structuring of keyword-only fields - #808
Open
leeshengis wants to merge 2 commits into
Open
leeshengis wants to merge 2 commits into
leeshengis wants to merge 2 commits into
Conversation
Preserve tuple field order while using constructor aliases for keyword-only parameters. Add attrs and dataclass regression tests and include keyword-only classes in the tuple property test. Fixes python-attrs#234.
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.
Closes #234.
structure_attrs_fromtuplecurrently passes every field to the constructor positionally, so attrs classes and dataclasses with keyword-only fields raiseTypeError.Keep conversion in tuple field order, but pass keyword-only values by their constructor names. Use attrs aliases (including private-field aliases), with the field name as the fallback for dataclasses. Positional arguments, omitted defaults and attribute-converter precedence retain their existing behavior.
Regression coverage includes both converter classes, class-wide and mixed keyword-only fields, inheritance, aliases, defaults and type conversion. The existing tuple property test now also generates keyword-only fields. A changelog entry is included.
Validation against main at
57333a2:BaseConverterandConverter.git diff --check, pass.Python 3.15, PyPy, performance benchmarks and upstream GitHub CI have not been run locally. This change does not address postponed annotations (#785) or
init=Falsefields.AI assistance was used for investigation, implementation and testing. I reviewed and approved this patch before submission and take responsibility for the contribution under the project's AI policy. There are no LLM co-author tags.