Skip to content

Fix regression from 2.6.1: ListBox used for tree implementation.#829

Merged
penguinolog merged 1 commit intourwid:masterfrom
penguinolog:fix_tree_listbox_render_empty_elements
Feb 21, 2024
Merged

Fix regression from 2.6.1: ListBox used for tree implementation.#829
penguinolog merged 1 commit intourwid:masterfrom
penguinolog:fix_tree_listbox_render_empty_elements

Conversation

@penguinolog
Copy link
Collaborator

  • Fix TreeWalker support in render
  • Cover issue with test
  • Add initial test for:
    • TreeNode
    • ParentNode
    • TreeWalker
    • TreeListBox
  • Add basic type annotations for tree widgets

Fix: #828

Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master or python-dual-support branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment
  • I've included docstrings and/or documentation and/or examples for my code (if this is a new feature)


widget, next_next_pos = self._body.get_next(next_pos)
if next_pos == next_next_pos:
raise ListBoxError(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cause infinite cycle (technically should be unreachable)

next_pos not in rendered_positions,
)
):
if widget.rows((maxcol,), False):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are here - calculate_visible is broken (main reason for this check)

@coveralls
Copy link

coveralls commented Feb 21, 2024

Pull Request Test Coverage Report for Build 7990924110

Details

  • -15 of 62 (75.81%) changed or added relevant lines in 2 files are covered.
  • 9 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.7%) to 72.074%

Changes Missing Coverage Covered Lines Changed/Added Lines %
urwid/listbox.py 6 8 75.0%
urwid/treetools.py 41 54 75.93%
Files with Coverage Reduction New Missed Lines %
urwid/listbox.py 9 83.9%
Totals Coverage Status
Change from base Build 7985804068: 0.7%
Covered Lines: 9070
Relevant Lines: 12663

💛 - Coveralls

" 1: child_1 ",
" 2: child_2 ",
" 3: child_3 ",
" ",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no next widgets, indexes are not int (main issue in regression)

def mouse_event(
self,
size,
size: tuple[int] | tuple[()],
Copy link
Collaborator Author

@penguinolog penguinolog Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Padding is FLOW/FIXED in this case

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we had 0 tests for trees

def load_child_keys(self):
def load_child_keys(self) -> Sequence[Hashable]:
"""Provide ParentNode with an ordered list of child keys (virtual function)"""
raise TreeWidgetError("virtual function. Implement in subclass")
Copy link
Collaborator Author

@penguinolog penguinolog Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, we should use NotImplementedError in all cases

widget = self.get_inner_widget()
if not self.is_leaf:
widget = urwid.Columns(
[("fixed", 1, [self.unexpanded_icon, self.expanded_icon][self.expanded]), widget],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deprecated, backward compatible GIVEN width

* Fix TreeWalker support in render
* Cover issue with test
* Add initial test for:
* * `TreeNode`
* * `ParentNode`
* * `TreeWalker`
* * `TreeListBox`
* Add basic type annotations for tree widgets

Fix: urwid#828
@penguinolog penguinolog force-pushed the fix_tree_listbox_render_empty_elements branch from 103ca87 to cc6d341 Compare February 21, 2024 14:47
@penguinolog penguinolog merged commit 2ee3584 into urwid:master Feb 21, 2024
@penguinolog penguinolog deleted the fix_tree_listbox_render_empty_elements branch February 21, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG?] unsupported operand type(s) for +: 'ParentNode' and 'int'

2 participants