Repository navigation
Shorten Tree's depth-first steps and SimpleTree's lookup helpers - #108
Merged
Merged
Conversation
next_position and prev_position return early instead of nesting, and prev_position returns the parent position directly. SimpleTree's helpers read self._treelist instead of taking it as an argument. Navigation still reads the data through _get_node, never through a subclass's __getitem__; a test now covers that. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Shortens
urwidtrees/tree.pywithout changing behaviour; found by an audit for over-engineering.Tree.next_positionandprev_positionreturn early instead of nesting, andprev_positionreturnsparent_position(pos)directly instead of copying it through aNonecheck.SimpleTree's private helpers_get_substructureand_get_nodereadself._treelistinstead of taking it as an argument that was alwaysself._treelist, and_confirm_posis one line.Navigation reads the tree's data through
_get_node, never through__getitem__, so a subclass that overrides__getitem__(to wrap or hide widgets) navigates as before.test_getitem_overridecovers that; it fails if_confirm_posgoes throughself[pos].Review findings and resolution
review-correctness
_confirm_poswent throughself[pos], so aSimpleTreesubclass overriding__getitem__changed navigation (raising or hiding positions): fixed, with a regression test._get_node/_get_substructuresignatures change: left; they are private and unused elsewhere.review-design
__getitem__coupling, with a subclass that never stopped walking: fixed, with the test asked for.parent_positionandlast_child_positionkeep the older style: left, to keep this change to what it states.🤖 Generated with Claude Code