From 1258068b24737e41e15e597e1f51c5eb36b2f271 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 21 Jun 2023 21:29:15 -0400 Subject: [PATCH] fix: support textual >=0.25 (#145) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.267 → v0.0.272](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.267...v0.0.272) - [github.com/codespell-project/codespell: v2.2.4 → v2.2.5](https://github.com/codespell-project/codespell/compare/v2.2.4...v2.2.5) * fix: bug with textual 0.25+ Signed-off-by: Henry Schreiner * chore: fix typing for latest textual Signed-off-by: Henry Schreiner * Update ci.yml --------- Signed-off-by: Henry Schreiner Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner --- .github/workflows/ci.yml | 1 - .pre-commit-config.yaml | 11 ++++++++--- src/uproot_browser/tui/browser.py | 2 +- src/uproot_browser/tui/left_panel.py | 19 +++++++++---------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 487376d..ba2e2b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,6 @@ jobs: checks: name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }} runs-on: ${{ matrix.runs-on }} - needs: [pre-commit] strategy: fail-fast: false matrix: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e34932..baf62e2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: "v0.0.267" + rev: "v0.0.272" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -29,10 +29,15 @@ repos: hooks: - id: mypy files: src - additional_dependencies: [rich>=12, click>=8.1.1, hist, numpy, textual>=0.24] + additional_dependencies: + - rich>=12 + - click>=8.1.1 + - hist + - numpy + - textual>=0.27 - repo: https://github.com/codespell-project/codespell - rev: v2.2.4 + rev: v2.2.5 hooks: - id: codespell args: [-L, "hist,iterm"] diff --git a/src/uproot_browser/tui/browser.py b/src/uproot_browser/tui/browser.py index 2c5bd25..4cb5c1a 100644 --- a/src/uproot_browser/tui/browser.py +++ b/src/uproot_browser/tui/browser.py @@ -49,7 +49,7 @@ ) -class Browser(textual.app.App[None]): +class Browser(textual.app.App[object]): """A basic implementation of the uproot-browser TUI""" CSS_PATH = "browser.css" diff --git a/src/uproot_browser/tui/left_panel.py b/src/uproot_browser/tui/left_panel.py index de8383f..78c3e14 100644 --- a/src/uproot_browser/tui/left_panel.py +++ b/src/uproot_browser/tui/left_panel.py @@ -57,6 +57,7 @@ def render_label( def on_mount(self) -> None: self.load_directory(self.root) + self.root.expand() def load_directory(self, node: textual.widgets.tree.TreeNode[UprootEntry]) -> None: assert node.data @@ -64,8 +65,6 @@ def load_directory(self, node: textual.widgets.tree.TreeNode[UprootEntry]) -> No children = node.data.children for child in children: node.add(child.path, child) - node.expand() - self.refresh(layout=True) def on_tree_node_selected( self, event: textual.widgets.Tree.NodeSelected[UprootEntry] @@ -89,19 +88,19 @@ def _node_expanded( self, node: textual.widgets.tree.TreeNode[UprootEntry] ) -> textual.widgets.Tree.NodeExpanded[UprootEntry]: try: - return self.NodeExpanded(self, node) - except TypeError: # textual < 0.24 - # pylint: disable-next=(no-value-for-parameter) - return self.NodeExpanded(node) # type:ignore[call-arg,arg-type] + return self.NodeExpanded(node) + except TypeError: # textual 0.24-0.26 + # pylint: disable-next=too-many-function-args + return self.NodeExpanded(self, node) # type:ignore[call-arg,arg-type] def _node_collapsed( self, node: textual.widgets.tree.TreeNode[UprootEntry] ) -> textual.widgets.Tree.NodeCollapsed[UprootEntry]: try: - return self.NodeCollapsed(self, node) - except TypeError: # textual < 0.24 - # pylint: disable-next=(no-value-for-parameter) - return self.NodeCollapsed(node) # type:ignore[call-arg,arg-type] + return self.NodeCollapsed(node) + except TypeError: # textual 0.24-0.26 + # pylint: disable-next=too-many-function-args + return self.NodeCollapsed(self, node) # type:ignore[call-arg,arg-type] def action_cursor_in(self) -> None: node = self.cursor_node