From 9dcbe2192d4faa315c77eaaad95d35ea5e6ef53c Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 6 Nov 2025 12:28:18 -0500 Subject: [PATCH] chore: add a few more ruff checks Signed-off-by: Henry Schreiner --- pyproject.toml | 17 +++++++++++++---- src/uproot_browser/_version.pyi | 2 -- src/uproot_browser/tree.py | 6 ++++-- src/uproot_browser/tui/browser.py | 6 ++++-- src/uproot_browser/tui/error.py | 5 ++++- src/uproot_browser/tui/left_panel.py | 6 ++++-- src/uproot_browser/tui/plot.py | 3 ++- 7 files changed, 31 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 47b3f49..2984108 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -132,31 +132,40 @@ messages_control.disable = [ [tool.ruff.lint] extend-select = [ - "B", # flake8-bugbear - "I", # isort "ARG", # flake8-unused-arguments + "B", # flake8-bugbear "C4", # flake8-comprehensions + "DTZ", # flake8-datetimez "EM", # flake8-errmsg + "EXE", # flake8-executable + "FA", # flake8-future-annotations + "FURB", # refurb + "G", # flake8-logging-format + "I", # isort "ICN", # flake8-import-conventions "ISC", # flake8-implicit-str-concat + "NPY", # NumPy specific rules + "PD", # pandas-vet + "PERF", # perflint "PGH", # pygrep-hooks "PIE", # flake8-pie "PL", # pylint "PT", # flake8-pytest-style "PTH", # flake8-use-pathlib + "PYI", # flake8-pyi "RET", # flake8-return "RUF", # Ruff-specific "SIM", # flake8-simplify + "SLOT", # flake8-slots "T20", # flake8-print + "TC", # flake8-type-checking "UP", # pyupgrade "YTT", # flake8-2020 ] ignore = [ - "E501", "E722", "RUF001", # Unicode chars "PLR", - "ISC001", # Conflicts with formatter ] unfixable = [ "SIM118", # Dict .keys() removal (uproot) diff --git a/src/uproot_browser/_version.pyi b/src/uproot_browser/_version.pyi index 91744f9..5bb2b22 100644 --- a/src/uproot_browser/_version.pyi +++ b/src/uproot_browser/_version.pyi @@ -1,4 +1,2 @@ -from __future__ import annotations - version: str version_tuple: tuple[int, int, int] | tuple[int, int, int, str, str] diff --git a/src/uproot_browser/tree.py b/src/uproot_browser/tree.py index bfdacf6..db4240f 100644 --- a/src/uproot_browser/tree.py +++ b/src/uproot_browser/tree.py @@ -6,9 +6,8 @@ import dataclasses import functools -from collections.abc import Iterable from pathlib import Path -from typing import Any, Literal, Protocol, TypedDict +from typing import TYPE_CHECKING, Any, Literal, Protocol, TypedDict import uproot import uproot.reading @@ -17,6 +16,9 @@ from rich.text import Text from rich.tree import Tree +if TYPE_CHECKING: + from collections.abc import Iterable + console = Console() __all__ = ( diff --git a/src/uproot_browser/tui/browser.py b/src/uproot_browser/tui/browser.py index 9d20f56..6770f45 100644 --- a/src/uproot_browser/tui/browser.py +++ b/src/uproot_browser/tui/browser.py @@ -4,7 +4,7 @@ __package__ = "uproot_browser.tui" # pylint: disable=redefined-builtin import contextlib -from typing import Any, ClassVar +from typing import TYPE_CHECKING, Any, ClassVar import plotext as plt import rich.syntax @@ -37,11 +37,13 @@ from .header import Header from .help import HelpScreen from .left_panel import UprootTree -from .messages import ErrorMessage, RequestPlot, UprootSelected from .plot import Plotext from .tools import Info, Tools from .viewer import ViewWidget +if TYPE_CHECKING: + from .messages import ErrorMessage, RequestPlot, UprootSelected + class Browser(textual.app.App[object]): """A basic implementation of the uproot-browser TUI""" diff --git a/src/uproot_browser/tui/error.py b/src/uproot_browser/tui/error.py index f65e502..be85ca1 100644 --- a/src/uproot_browser/tui/error.py +++ b/src/uproot_browser/tui/error.py @@ -1,11 +1,14 @@ from __future__ import annotations import dataclasses -from types import TracebackType +from typing import TYPE_CHECKING import rich.console import rich.traceback +if TYPE_CHECKING: + from types import TracebackType + @dataclasses.dataclass class Error: diff --git a/src/uproot_browser/tui/left_panel.py b/src/uproot_browser/tui/left_panel.py index b1821d3..4064e8f 100644 --- a/src/uproot_browser/tui/left_panel.py +++ b/src/uproot_browser/tui/left_panel.py @@ -1,7 +1,7 @@ from __future__ import annotations from pathlib import Path -from typing import Any, ClassVar +from typing import TYPE_CHECKING, Any, ClassVar import rich.panel import rich.text @@ -10,11 +10,13 @@ import textual.widgets import textual.widgets.tree import uproot -from rich.style import Style from ..tree import UprootEntry from .messages import UprootSelected +if TYPE_CHECKING: + from rich.style import Style + class UprootTree(textual.widgets.Tree[UprootEntry]): """currently just extending DirectoryTree, showing current path""" diff --git a/src/uproot_browser/tui/plot.py b/src/uproot_browser/tui/plot.py index 46a8b8a..1eb3514 100644 --- a/src/uproot_browser/tui/plot.py +++ b/src/uproot_browser/tui/plot.py @@ -2,7 +2,6 @@ import dataclasses import sys -from collections.abc import Iterable from typing import TYPE_CHECKING, Any import plotext as plt # plots in text @@ -15,6 +14,8 @@ from .messages import EmptyMessage, ErrorMessage, RequestPlot if TYPE_CHECKING: + from collections.abc import Iterable + from .browser import Browser