Skip to content

fix child naming - #38

Merged
wpbonelli merged 3 commits into
developfrom
child-naming
Sep 14, 2026
Merged

wpbonelli merged 3 commits into
developfrom
child-naming

Conversation

@wpbonelli

Copy link
Copy Markdown
Owner

don't forget your kids' names

wpbonelli and others added 3 commits September 14, 2026 14:08
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
wpbonelli merged commit 8349473 into develop Sep 14, 2026
22 checks passed
@wpbonelli
wpbonelli deleted the child-naming branch September 14, 2026 18:52
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant