Repository navigation
fix child naming - #38
Merged
Merged
Conversation
xattree had two divergent code paths for attaching a child to a parent (constructor-kwarg/attribute-assignment vs. standalone-then-parent=), plus dict-kind's own separate keying scheme, each with different rules for whether an explicit name sticks and what an unnamed child gets called. dict-kind also let same-named children from different fields on the same parent silently clobber each other, since tree.children is one flat mapping per node rather than one per field. Add a shared _resolve_child_name helper and wire it through _yield_children, _bind_tree's parent-attach logic, and _setattr's Child-field-assignment branch, so all three attachment paths agree: an explicit name always sticks as the real key, an unnamed child gets today's field-name-based default (unchanged, so this is additive for existing unnamed callers), and any collision across a parent's whole child namespace raises immediately instead of overwriting -- except an auto-generated name, which avoids colliding in the first place rather than raising. Also fix _getattr's only-kind lookup to scan by type instead of an exact match on field name, since a child's key is no longer guaranteed to equal its field name. Add test/test_child_naming.py covering both attachment paths for both only- and list-kind fields, the getattr visibility fix, and the cross-field collision cases. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LEvJnWvRx8wjVx8rYRdyVn
wpbonelli
added a commit
to wpbonelli/pyphoenix-project
that referenced
this pull request
Sep 14, 2026
MODFLOW-ORG/modflow-devtools#358 (migration-time fixup marking gwt-ssm/ gwe-ssm's SOURCES block write_if_empty) merged upstream. Confirmed live against the real DFNs (Block.write_if_empty is True for both components' sources block via LocalDfnRegistry), and a forced re-sync of flopy4.mf6 produces a zero diff -- the previously-added always_emit heuristic already produced the same generated output, so this just makes the authoritative signal take over silently. Pinned xattree back to its previous resolved commit (9fde8f0) in this same lock regen: the full `pixi lock` rebuild (required to force any unpinned git dependency to refresh) incidentally also picked up wpbonelli/xattree#38 ("fix child naming"), which is unrelated in-progress work and broke 3 unrelated tests (package name/pname reconciliation, netcdf variable naming). Decoupled so this branch only carries the devtools bump; xattree's update should land through its own work separately. Updated the always_emit comment in make.py: write_if_empty is now genuinely live for gwt-ssm/gwe-ssm (not just wired for later), with the heuristic remaining only as a fallback for the blocks it doesn't cover yet (gwt-lkt/gwe-lke packagedata, LAK connectiondata). Full suite back to baseline: 893 passed, 12 skipped, 4 xfailed. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HCtSfgvTfsJrhugnXk3qgA
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.
don't forget your kids' names