aboutsummaryrefslogtreecommitdiffstats
path: root/ruff.toml
diff options
context:
space:
mode:
authorblasty <peter@haxx.in>2026-08-21 12:14:27 +0200
committerblasty <peter@haxx.in>2026-08-21 12:14:27 +0200
commit93ca90558aa6016e77625c627a70640e693e3303 (patch)
tree284dfb0d126aefd0bb69f517ec64ca12d2130bcb /ruff.toml
parenttests: repair the two seams the ida-nexus port left behind (diff)
downloadida-tui-93ca90558aa6016e77625c627a70640e693e3303.tar.gz
ida-tui-93ca90558aa6016e77625c627a70640e693e3303.tar.xz
ida-tui-93ca90558aa6016e77625c627a70640e693e3303.zip
adopt ruff: pinned formatter + import sorting, opt-in pre-commit hook
PR #1 arrived black-formatted, which forced the question. ruff's formatter is black's output, it is one static binary rather than a dependency chain, and it is fast enough that a hook is free. ruff.toml pins the version (a formatter whose output moves between releases turns 'formatted' into 'formatted by whoever committed last') and selects only import sorting on the lint side -- a hook that refused a commit over an unused variable would be a different feature. .githooks/pre-commit (install: git config core.hooksPath .githooks) formats exactly what is staged, refuses partly-staged files rather than quietly widening a commit built with git add -p, and prefers the pinned .venv ruff. Also drops the blanket '# ruff: noqa' PR #1 left in remote_ops.py -- it would have exempted that file from the only lint rule we enforce.
Diffstat (limited to 'ruff.toml')
-rw-r--r--ruff.toml33
1 files changed, 33 insertions, 0 deletions
diff --git a/ruff.toml b/ruff.toml
new file mode 100644
index 0000000..6d0f877
--- /dev/null
+++ b/ruff.toml
@@ -0,0 +1,33 @@
+# How the Python in this tree is formatted, and how its imports are ordered.
+# `.githooks/pre-commit` applies both to what you staged (install it with
+# `git config core.hooksPath .githooks`); `ruff format --check .` asks.
+#
+# Adopted when PR #1 arrived black-formatted: ruff's formatter IS black's
+# output, it is one static binary instead of a Python dependency chain, and it
+# is fast enough that a pre-commit hook is free. Configuration is deliberately
+# left at the defaults -- every knob turned here is an argument somebody has to
+# have again later.
+
+# The version this tree was formatted with, enforced by ruff itself: a
+# formatter whose output moves between releases turns "formatted" into
+# "formatted by whoever committed last", and the diff lands on the next
+# person. A mismatch is refused with both versions named rather than quietly
+# reformatting everything. Bumping it is one line here, one in the hook's
+# install hint, and a reformat commit (added to .git-blame-ignore-revs) --
+# the honest cost of a new version.
+required-version = "==0.16.3"
+
+target-version = "py311"
+line-length = 88
+
+[lint]
+# Import sorting, and nothing else. `ruff check` can enforce a great deal more
+# and one day it might, but this hook's job is formatting: one that also
+# refused a commit over an unused variable would be a different feature, and
+# not one anybody asked for.
+#
+# Sorting is safe here because ruff sorts import BLOCKS and never hoists across
+# a statement: every test file's `sys.path.insert(...)` sits between the
+# standard library and the `idatui` imports, and that line is exactly what
+# makes them importable.
+select = ["I"]