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 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/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 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.