chore(lint): keep ruff.toml as the only ruff config

Ruff reads ruff.toml and ignores [tool.ruff] in pyproject.toml when both
exist, so the pyproject block was never applied: PLW1514
(unspecified-encoding), which that block called too load-bearing to keep
off and lint.yml said the blocking step enforces, was not enforced. Its
ASYNC baseline list was stale for the same reason: ruff.toml already
selects those rules with no baseline and the tree passes.

- ruff.toml selects PLW1514 and turns on preview only for preview rules
  it names (explicit-preview-rules). That also activates PLE0304,
  PLR1708, RUF063, RUF068 and FURB192, which were selected but skipped
  with a "preview is not enabled" warning.
- PLW1514 stays off for tests/, skills/, optional-skills/ and plugins/,
  carried over from the pyproject block.
- [tool.ruff*] leaves pyproject.toml; ruff.pre-commit.toml (a copy of
  ruff.toml that differed by one comma) is deleted, and `just ruff`
  (the lefthook pre-commit step) uses ruff.toml.
- lint.yml's comments name ruff.toml.
This commit is contained in:
alt-glitch
2026-11-15 13:07:21 +05:30
committed by Siddharth Balyan
parent 7defffc296
commit b7f657fc5e
5 changed files with 18 additions and 554 deletions

View File

@@ -5,8 +5,7 @@ name: Lint (ruff + ty)
# whether or not the others failed (`!cancelled()`), so one red check never hides another:
# 1. Windows footguns and sibling static guards (blocking, `python`). They run first, on the
# setup-pm interpreter, before the pinned-tool install below re-points `python`.
# 2. Blocking ``ruff check .`` (`python`) — enforces the explicit rules in
# ``[tool.ruff.lint.select]`` (currently PLW1514).
# 2. Blocking ``ruff check .`` (`python`) — enforces the rules selected in ``ruff.toml``.
# 3. Blocking code-health ratchet (``scripts/code_health``) for Python and TypeScript (PRs).
# 4. Advisory ruff + ty diff vs the target branch (PRs, `python`). Writes a Markdown summary
# to the run page and never fails the job.
@@ -193,11 +192,10 @@ jobs:
# ── Blocking ruff (python lane) ────────────────────────────────────────────────────────
# Enforce the rules in pyproject.toml [tool.ruff.lint.select]. Currently
# PLW1514 (unspecified-encoding) — catches bare ``open()`` /
# ``read_text()`` / ``write_text()`` calls that default to locale
# encoding on Windows. No --exit-zero, no || true: the exit code fails the
# job, which fails the required-check gate.
# Enforce the rules selected in ruff.toml, the only ruff config (PLW1514 among them:
# bare ``open()`` / ``read_text()`` / ``write_text()`` calls that default to the locale
# encoding on Windows). No --exit-zero, no || true: the exit code fails the job, which
# fails the required-check gate.
- name: ruff check .
if: ${{ !cancelled() && steps.tools.outcome == 'success' && inputs.python }}
run: |

View File

@@ -190,11 +190,11 @@ termux-payload payload +packages:
lock:
scripts/relock.sh
# Pre-commit: the pinned ruff with ruff.pre-commit.toml on the given files
# Pre-commit: the pinned ruff with ruff.toml on the given files
[group('hooks')]
[positional-arguments]
ruff +files:
scripts/hermes-python -m scripts.code_health.ruff_runner check --config ruff.pre-commit.toml "$@"
scripts/hermes-python -m scripts.code_health.ruff_runner check "$@"
# Pre-commit: eslint on the given files, from the calling workspace
[group('hooks')]

View File

@@ -784,75 +784,3 @@ python-version = "3.13"
[tool.ty.rules]
unknown-argument = "warn"
redundant-cast = "ignore"
[tool.ruff]
preview = true # required for PLW1514 (unspecified-encoding) — preview rule
[tool.ruff.lint]
# All other lints are intentionally disabled (see comment history on this
# file) while we wrangle typechecks — but PLW1514 is too load-bearing to
# keep off. Bare open()/read_text()/write_text() in text mode defaults to
# the system locale encoding on Windows (cp1252 on US-locale installs),
# which silently corrupts any non-ASCII file content. We had three
# separate Windows sandbox regressions in one debug session before
# adding the explicit encoding. This rule keeps new code honest.
#
# ASYNC210/220/221/251: blocking calls inside `async def` freeze the whole
# gateway/uvicorn event loop — every adapter, timer, and health check stops
# until the call returns. Real incidents: a 17-minute getaddrinfo hang took
# the backend down (#91912); `time.sleep` in start_gateway froze restarts
# for 10s (#36163). The fix pattern is `await asyncio.to_thread(...)` (or
# `loop.run_in_executor`), `asyncio.create_subprocess_exec`, and
# `await asyncio.sleep`. These four are the direct freeze vectors:
# ASYNC210 — blocking HTTP call in async fn (urllib/requests/httpx-sync)
# ASYNC220 — subprocess.Popen in async fn
# ASYNC221 — subprocess.run / os.system in async fn
# ASYNC251 — time.sleep in async fn
# ASYNC230 (blocking open()) and ASYNC240 (blocking path methods) are real
# but ~180 legacy sites deep; they graduate to this list once the backlog
# is burned down (see per-file-ignores below for the frozen baseline).
select = ["PLW1514", "ASYNC210", "ASYNC220", "ASYNC221", "ASYNC251", "TID251"]
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"pm.uv".msg = "Use PM's semantic Python operations, not an installer executable."
"pm.client.uv".msg = "Use PM's semantic Python operations."
"pm.install.uv".msg = "The raw uv bridge was removed; use PM operations."
"pm._uv".msg = "Tool acquisition is private to PM."
"pm.environment".msg = "The environment engine is private; use PM operations."
"pm.runtime_stage".msg = "PM stages its own worker runtime; consumers call pm operations."
[tool.ruff.lint.per-file-ignores]
"pm/**" = ["TID251"]
# Desktop E2E fixtures stand in for PM's worker/runtime and reach into it like tests do.
"apps/desktop/electron/fixtures/**" = ["TID251"]
# Tests can intentionally exercise locale-encoding edge cases.
"tests/**" = [
"PLW1514",
"ASYNC210",
"ASYNC220",
"ASYNC221",
"ASYNC251",
"TID251",
]
# Skills and plugins are partially user-authored — their own conventions.
"skills/**" = ["PLW1514"]
"optional-skills/**" = ["PLW1514"]
# Plugin platform adapters run ON the gateway event loop — the ASYNC gate
# applies to them with full force; only PLW1514 stays relaxed.
"plugins/**" = ["PLW1514"]
# ---------------------------------------------------------------------------
# ASYNC ratchet baseline — legacy blocking sites that predate the gate.
# Each entry is an EXISTING violation being fixed in its own PR; do NOT add
# new files here. Remove the entry when the file's sites are fixed.
# ---------------------------------------------------------------------------
# Detached restart watchers: Popen of a fully-detached, fire-and-forget
# process (no wait), an accepted momentary spawn cost pending a dedicated
# async-subprocess sweep.
"gateway/run.py" = ["ASYNC220"]
"gateway/run_shutdown.py" = ["ASYNC220"]
"gateway/slash_commands.py" = ["ASYNC220"]
# Off-loop sweep for these routers is in flight (PR #84376).
"hermes_cli/web_routers/profiles.py" = ["ASYNC220", "ASYNC221"]
# Legacy blocking spawn sites in platform adapters, pending their own fixes.
"plugins/platforms/whatsapp/adapter.py" = ["ASYNC220", "ASYNC221"]
"plugins/platforms/photon/adapter.py" = ["ASYNC220"]

View File

@@ -1,473 +0,0 @@
# Same as Black.
line-length = 88
indent-width = 4
# The oldest Python we support (requires-python): quote-stripping (UP037) and every other
# version-gated fix must stay valid where annotations are evaluated eagerly (< 3.14).
target-version = "py311"
[format]
# Like Black, use double quotes for strings.
quote-style = "double"
# Like Black, indent with spaces, rather than tabs.
indent-style = "space"
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
[lint]
exclude = [
".bzr",
".git",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".venv",
".vscode",
"__pypackages__",
]
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
select = [
"YTT101",
"YTT102",
"YTT103",
"YTT201",
"YTT202",
"YTT203",
"YTT204",
"YTT301",
"YTT302",
"YTT303",
"ASYNC100",
"ASYNC105",
"ASYNC115",
"ASYNC116",
"ASYNC210",
"ASYNC220",
"ASYNC221",
"ASYNC222",
"ASYNC230",
"ASYNC251",
# "S102",
# "S110",
# "S112",
# "BLE001",
"B002",
"B003",
"B004",
"B005",
"B006",
# "B008",
"B009",
"B010",
"B012",
"B013",
"B014",
"B015",
"B016",
# "B017",
# "B018",
"B019",
"B020",
"B021",
# "B022",
# "B023",
"B025",
# "B026",
"B029",
# "B030",
"B031",
"B032",
"B033",
"B035",
# "B039",
"C400",
# "C401",
# "C402",
"C403",
"C404",
"C405",
# "C406",
# "C408",
# "C409",
"C410",
"C411",
# "C413",
"C414",
"C415",
# "C417",
"C418",
# "C419",
# "C901",
# "DTZ001",
"DTZ002",
# "DTZ003",
"DTZ004",
# "DTZ005",
# "DTZ006",
# "DTZ007",
# "DTZ011",
"DTZ012",
"DTZ901",
"T100",
# "EXE001",
# "EXE002",
"EXE004",
"EXE005",
"FA100",
"FA102",
"INT001",
"INT002",
"INT003",
# "ISC004",
# "LOG001",
"LOG002",
"LOG009",
# "LOG014",
# "LOG015",
"G010",
"G101",
# "G201",
"G202",
"PIE790",
"PIE794",
"PIE796",
"PIE800",
"PIE804",
"PIE807",
"PIE808",
# "PIE810",
"PYI001",
"PYI002",
"PYI003",
"PYI004",
"PYI005",
"PYI006",
"PYI007",
"PYI008",
"PYI009",
"PYI010",
"PYI012",
"PYI013",
"PYI015",
"PYI016",
"PYI017",
"PYI018",
"PYI019",
"PYI020",
"PYI025",
"PYI026",
"PYI029",
"PYI030",
"PYI032",
"PYI033",
# "PYI034",
"PYI035",
"PYI036",
"PYI041",
"PYI042",
"PYI043",
"PYI044",
"PYI045",
"PYI046",
"PYI047",
"PYI048",
"PYI049",
"PYI050",
"PYI052",
"PYI055",
"PYI057",
"PYI058",
"PYI059",
"PYI061",
"PYI062",
"PYI063",
"PYI064",
"PYI066",
"PT010",
# "PT014",
"PT020",
"PT025",
"PT026",
"PT031",
"RET501",
"SIM101",
# "SIM102",
# "SIM103",
"SIM107",
# "SIM113",
"SIM114",
# "SIM115",
# "SIM117",
# "SIM118",
# "SIM201",
"SIM202",
"SIM208",
"SIM210",
# "SIM211",
"SIM220",
"SIM221",
"SIM222",
"SIM223",
# "SIM401",
# "SIM905",
"SIM911",
"TC004",
"TC005",
"TC007",
"TC010",
"PTH124",
"PTH210",
# "FLY002",
# "I001",
# "N999",
"PERF101",
# "PERF102",
"PERF402",
"E722",
"E902",
"W605",
"D419",
# "F401",
# "F402",
"F404",
"F407",
"F501",
"F502",
"F503",
"F504",
"F505",
"F506",
"F507",
"F508",
"F509",
"F521",
"F522",
"F523",
"F524",
"F525",
"F541",
# "F601",
"F602",
"F621",
"F622",
"F631",
"F632",
"F633",
"F634",
"F701",
"F702",
"F704",
"F706",
"F707",
# "F811",
# "F821",
"F822",
"F823",
"F841",
"F842",
"F901",
"PGH005",
"PLC0105",
"PLC0131",
"PLC0132",
"PLC0205",
"PLC0206",
"PLC0208",
"PLC0414",
"PLC3002",
"PLE0100",
"PLE0101",
"PLE0115",
"PLE0116",
"PLE0117",
"PLE0118",
"PLE0303",
"PLE0304",
"PLE0305",
"PLE0307",
"PLE0308",
"PLE0309",
"PLE0604",
# "PLE0605",
"PLE0643",
# "PLE0704",
"PLE1132",
"PLE1142",
"PLE1205",
"PLE1206",
"PLE1300",
"PLE1307",
"PLE1310",
"PLE1507",
"PLE1519",
"PLE1520",
"PLE1700",
# "PLE2502",
"PLE2510",
"PLE2512",
"PLE2513",
"PLE2514",
"PLE2515",
# "PLR0124",
"PLR0133",
"PLR0206",
"PLR0402",
# "PLR1704",
"PLR1708",
"PLR1711",
"PLR1716",
"PLR1722",
"PLR1730",
"PLR1733",
"PLR1736",
"PLR2044",
"PLW0120",
"PLW0127",
"PLW0128",
"PLW0129",
"PLW0131",
"PLW0133",
"PLW0177",
"PLW0211",
"PLW0245",
"PLW0406",
# "PLW0602",
"PLW0604",
"PLW0642",
"PLW0711",
"PLW1501",
"PLW1507",
# "PLW1508",
"PLW1509",
"PLW1510",
"PLW2101",
"UP001",
"UP003",
"UP004",
"UP005",
"UP006",
"UP007",
"UP008",
"UP009",
"UP010",
"UP011",
"UP012",
"UP014",
"UP017",
"UP018",
"UP019",
"UP020",
"UP021",
"UP022",
"UP023",
"UP024",
"UP025",
"UP026",
"UP028",
"UP029",
"UP030",
"UP031",
"UP032",
"UP033",
"UP034",
# "UP035",
"UP036",
"UP037",
"UP039",
"UP040",
"UP041",
"UP043",
"UP044",
#"UP045",
# "UP046", # deferred: fix is PEP 695 class syntax (3.12+), project floor is py3.11
# "UP047", # deferred: fix is PEP 695 generic-callable syntax (3.12+), project floor is py3.11
"UP049",
"UP050",
"FURB105",
"FURB122",
"FURB129",
"FURB132",
"FURB136",
"FURB157",
"FURB161",
"FURB162",
"FURB163",
"FURB166",
"FURB167",
"FURB168",
"FURB169",
"FURB177",
"FURB181",
"FURB188",
"FURB192",
"RUF007",
"RUF008",
"RUF009",
"RUF010",
# "RUF012",
"RUF013",
"RUF015",
"RUF016",
"RUF017",
"RUF018",
"RUF019",
"RUF020",
"RUF022",
"RUF023",
"RUF024",
"RUF026",
"RUF028",
"RUF030",
"RUF032",
"RUF033",
"RUF034",
"RUF040",
"RUF041",
"RUF046",
"RUF048",
"RUF049",
"RUF051",
"RUF053",
"RUF057",
"RUF058",
"RUF059",
"RUF063",
"RUF068",
"RUF100",
"RUF101",
"RUF200",
# "TRY002",
# "TRY004",
# "TRY201",
# "TRY203",
# "TRY401",
"TID251"
]
[lint.flake8-tidy-imports.banned-api]
"pm.uv".msg = "Use PM's semantic Python operations, not an installer executable."
"pm.client.uv".msg = "Use PM's semantic Python operations."
"pm.install.uv".msg = "The raw uv bridge was removed; use PM operations."
"pm._uv".msg = "Tool acquisition is private to PM."
"pm.environment".msg = "The environment engine is private; use PM operations."
"pm.runtime_stage".msg = "PM stages its own worker runtime; consumers call pm operations."
[lint.per-file-ignores]
"apps/desktop/electron/fixtures/**" = ["TID251"]
"tests/pm/**" = ["TID251"]
[lint.mccabe]
max-complexity = 20

View File

@@ -20,6 +20,9 @@ skip-magic-trailing-comma = false
line-ending = "auto"
[lint]
# Preview is on only for the preview rules this file selects by exact code (PLW1514 below).
preview = true
explicit-preview-rules = true
exclude = [
".bzr",
".git",
@@ -353,6 +356,7 @@ select = [
# "PLW1508",
"PLW1509",
"PLW1510",
"PLW1514",
"PLW2101",
"UP001",
"UP003",
@@ -468,6 +472,13 @@ select = [
[lint.per-file-ignores]
"apps/desktop/electron/fixtures/**" = ["TID251"]
"tests/pm/**" = ["TID251"]
# PLW1514: a text-mode open() without an encoding uses the locale codec on Windows (cp1252 on
# US installs) and corrupts non-ASCII content. Tests exercise locale edge cases on purpose, and
# skills and plugins follow their authors' conventions.
"tests/**" = ["PLW1514"]
"skills/**" = ["PLW1514"]
"optional-skills/**" = ["PLW1514"]
"plugins/**" = ["PLW1514"]
[lint.mccabe]
max-complexity = 20