Skip to content

Shorten the collapse icon and ArrowTree line construction - #109

Merged
pazz merged 1 commit into
mainfrom
decoration-shrink
Oct 25, 2026
Merged

pazz merged 1 commit into
mainfrom
decoration-shrink

Conversation

@pazz

@pazz pazz commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Shortens urwidtrees/decoration.py without changing behaviour or rendering; found by an audit for over-engineering.

  • CollapseIconMixin._construct_collapse_icon builds the left frame, icon and right frame in one loop instead of three copied blocks.
  • ArrowTree.decorate returns early for None, drops a second self._indent > 0 check inside a branch that already made it, and drops dead assignments and an always-true None check.
  • ArrowTree._construct_connector picks the character first and drops its dead initialisations.
  • CollapsibleIndentedTree.decorate and CollapseIconMixin.__init__ lose leftover TODOs, a dead assignment and a stray tuple (cols.append(...),).

Rendering every position of a set of trees through every decorator with indents 0 to 8, all arrow and icon options, collapse states and NestedTree gives byte-identical output on main and this branch (about 88,700 records), under urwid 3.0.4 and 2.1.2, including the cases that raise NoSpaceError.

Review findings and resolution

review-correctness

  • A third-party subclass overriding the private _construct_first_indent to return None would now get a TypeError: left; the method never returns None and nothing overrides it.
  • Checked without findings: the rendering comparison above; callers of the changed methods; timing on a 1200-level chain and 10000 children.

review-design

  • CollapsibleIndentedTree.decorate could return its Columns directly, and _construct_connector had dead initialisations: both done.
  • CollapseIconMixin.__init__ is left without a docstring: left; the placeholder said nothing.

🤖 Generated with Claude Code

_construct_collapse_icon builds the frame and icon parts in one loop,
ArrowTree.decorate returns early and drops a repeated indent check and
dead assignments, _construct_connector loses its dead initialisations,
and CollapsibleIndentedTree.decorate and CollapseIconMixin lose
leftover TODOs and a stray tuple.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pazz
pazz merged commit 4e35283 into main Oct 25, 2026
4 checks passed
@pazz
pazz deleted the decoration-shrink branch October 25, 2026 11:31
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