Forbid path-like DataTree child names #9490#11014
Open
eshort0401 wants to merge 2 commits intopydata:mainfrom
Open
Forbid path-like DataTree child names #9490#11014eshort0401 wants to merge 2 commits intopydata:mainfrom
eshort0401 wants to merge 2 commits intopydata:mainfrom
Conversation
Contributor
Author
|
I've just realized this PR is very similar to @TomNicholas's PR #9492 from 2024, sorry! Happy to update authorship in the |
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.
DataTreecauses aRecursionError#9978whats-new.rstAddresses #9490 and #9978 by forbidding the
/character inDataTreechild names.DataTreenode names are already checked using_validate_namefrom thetreenodemodule. I therefore call this function inside the_check_childrenmember function ofTreeNode. This check ensures invalidchildrenarguments are caught early in theDataTreeconstructor, and when theDataTree.childrenattribute is reset explicitly (see Set child nodes via DataTree.children #9441). I have also reworded the_validate_nameerror message slightly for consistency with_check_for_slashes_in_names(defined in thedatatreemodule) which checks variable names. To illustrate, code like_check_childrenon the inputchildrenmapping given to theDataTreeconstructor, before it is assigned and the setter function is called. This additional check ensures that if the user passes a badchildren, a helpful error message is given before the shallow copy{name: child.copy() for name, child in children.items()}fails.DataTree.__init__docstring to communicate that/characters are forbidden in both thenameargument, and the keys of thechildrenmapping argument.Additional Notes
This PR follows after discussion with @TomNicholas in #11001. See also #9441 and #9477.