From 924b2c50facdc98a963bdafc157edde3da9d2c56 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Sat, 7 Feb 2026 10:05:01 +0000 Subject: [PATCH 1/3] :shirt: Tighten linting rules --- Makefile | 2 +- pyproject.toml | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f355f2f..3f65883 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ publish := uv publish --username=__token__ --keyring-provider=subprocess test := $(run) pytest python := $(run) python ruff := $(run) ruff -lint := $(ruff) check --select I +lint := $(ruff) check fmt := $(ruff) format mypy := $(run) mypy mkdocs := $(run) mkdocs diff --git a/pyproject.toml b/pyproject.toml index 715d93b..11fe112 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,3 +70,26 @@ explicit = true venvPath="." venv=".venv" exclude=[".venv"] + +[tool.ruff.lint] +select = [ + # pycodestyle + "E", + # Pyflakes + "F", + # pyupgrade + "UP", + # flake8-bugbear + "B", + # flake8-simplify + "SIM", + # isort + "I", +] +ignore = [ + # I think try...expect...pass reads far better. + "SIM105", +] + +[tool.ruff.lint.pycodestyle] +max-line-length = 120 From 9c1b38e4b1e2b46f0d8f8c1b8340b54f65be2cfd Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Sat, 7 Feb 2026 10:07:55 +0000 Subject: [PATCH 2/3] :shirt: Update type hints to a more modern approach --- src/textual_enhanced/commands/bindings.py | 6 ++++-- src/textual_enhanced/commands/provider.py | 3 ++- src/textual_enhanced/screen.py | 3 ++- src/textual_enhanced/tools/history.py | 3 ++- tests/test_history.py | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/textual_enhanced/commands/bindings.py b/src/textual_enhanced/commands/bindings.py index a3a4421..5faf175 100644 --- a/src/textual_enhanced/commands/bindings.py +++ b/src/textual_enhanced/commands/bindings.py @@ -1,9 +1,11 @@ """Provides helper code for dealing with bindings.""" ############################################################################## -# Textual imports. -from typing import Iterator +# Python imports. +from collections.abc import Iterator +############################################################################## +# Textual imports. from textual.app import App from textual.binding import Binding from textual.dom import DOMNode diff --git a/src/textual_enhanced/commands/provider.py b/src/textual_enhanced/commands/provider.py index 11255b6..fff6a02 100644 --- a/src/textual_enhanced/commands/provider.py +++ b/src/textual_enhanced/commands/provider.py @@ -3,8 +3,9 @@ ############################################################################## # Python imports. from abc import abstractmethod +from collections.abc import Iterator from functools import partial -from typing import Iterator, NamedTuple, TypeAlias +from typing import NamedTuple, TypeAlias ############################################################################## # Rich imports. diff --git a/src/textual_enhanced/screen.py b/src/textual_enhanced/screen.py index 82ea2b3..e1a37bf 100644 --- a/src/textual_enhanced/screen.py +++ b/src/textual_enhanced/screen.py @@ -2,8 +2,9 @@ ############################################################################## # Python imports. +from collections.abc import Iterator from contextlib import contextmanager -from typing import Generic, Iterator +from typing import Generic ############################################################################## # Textual imports. diff --git a/src/textual_enhanced/tools/history.py b/src/textual_enhanced/tools/history.py index ec7d8ad..38e8313 100644 --- a/src/textual_enhanced/tools/history.py +++ b/src/textual_enhanced/tools/history.py @@ -3,7 +3,8 @@ ############################################################################## # Python imports. from collections import deque -from typing import Generic, Iterator, Sequence, TypeVar +from collections.abc import Iterator, Sequence +from typing import Generic, TypeVar ############################################################################## # Textual imports. diff --git a/tests/test_history.py b/tests/test_history.py index e35fd8d..71a88d3 100644 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -2,7 +2,7 @@ ############################################################################## # Python imports. -from typing import Sequence +from collections.abc import Sequence ############################################################################## # Pytest imports. From 5c6e9539077f1c31a2a7bb5417df37c4ef2ecf47 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Sat, 7 Feb 2026 10:13:23 +0000 Subject: [PATCH 3/3] :art: Reduce some long line lengths --- src/textual_enhanced/dialogs/help.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/textual_enhanced/dialogs/help.py b/src/textual_enhanced/dialogs/help.py index f639fc1..9638159 100644 --- a/src/textual_enhanced/dialogs/help.py +++ b/src/textual_enhanced/dialogs/help.py @@ -116,9 +116,16 @@ def input_help(self, node: DOMNode) -> str: for binding in sorted( helpful_bindings, key=attrgetter("most_helpful_description") ): - keys += f"{'| ' if commands else ''}| {self._table_safe(', '.join(all_keys_for(node, binding)))} | {binding.most_helpful_description} |\n" + keys += ( + f"{'| ' if commands else ''}| " + f"{self._table_safe(', '.join(all_keys_for(node, binding)))} " + f"| {binding.most_helpful_description} |\n" + ) for command in sorted(commands, key=methodcaller("command")): - keys += f"| {command.command()} | {self._table_safe(', '.join(all_keys_for(node, command)))} | {command.tooltip()} |\n" + keys += ( + f"| {command.command()} " + f"| {self._table_safe(', '.join(all_keys_for(node, command)))} | {command.tooltip()} |\n" + ) return f"\n\n{keys}" @property