Skip to content

Commit

Permalink
fix: support textual >=0.25 (#145)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/charliermarsh/ruff-pre-commit: v0.0.267 → v0.0.272](astral-sh/ruff-pre-commit@v0.0.267...v0.0.272)
- [github.com/codespell-project/codespell: v2.2.4 → v2.2.5](codespell-project/codespell@v2.2.4...v2.2.5)

* fix: bug with textual 0.25+

Signed-off-by: Henry Schreiner <[email protected]>

* chore: fix typing for latest textual

Signed-off-by: Henry Schreiner <[email protected]>

* Update ci.yml

---------

Signed-off-by: Henry Schreiner <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and henryiii committed Jun 22, 2023
1 parent a80297d commit 1258068
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 8 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion src/uproot_browser/tui/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 9 additions & 10 deletions src/uproot_browser/tui/left_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@ 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
if not node.children:
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]
Expand All @@ -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
Expand Down

0 comments on commit 1258068

Please sign in to comment.