Skip to content

typos-format/ruff-format: opt-in config grep misses TOML inline-table form for [tool.X] #876

Description

@kyle-sexton

Summary

Both typos-format's pyproject.toml/Cargo.toml opt-in check and ruff-format's pyproject.toml opt-in check use a line-anchored grep for a [tool.X] section header:

grep -qE '^[[:space:]]*\[tool\.typos(\]|[.])' "$dir/pyproject.toml"
grep -qE '^[[:space:]]*\[tool\.ruff(\]|[.])'  "$dir/pyproject.toml"

TOML allows the equivalent configuration as an inline table under a [tool] header instead:

[tool]
typos = { default = { extend-words = { ... } } }

Both tools (verified empirically for typos-cli 1.44.0) honor this form when actually run. Neither hook's grep recognizes it, so a repo using this style is treated as "no config" and the hook silently skips — a false-negative on the opt-in gate, not an incorrect correction.

Impact

Low. Inline-table syntax for an entire [tool.X] section is unusual in practice — TOML style strongly favors the [tool.X] header form for anything beyond a single scalar value. Surfaced by Codex review on #872 (typos-format), applies identically to the already-shipped ruff-format.

Why not fixed inline

A robust fix needs real TOML parsing (inline tables can span multiple lines, nest arbitrarily, and the typos/ruff key can appear in any order within [tool]). A multi-pass grep heuristic ("has [tool]" + "has a typos = or ruff = line somewhere after it") risks false positives from an unrelated typos = \"...\"/ruff = \"...\" key in a different table, or from commented-out lines. Out of scope for a fast, dependency-free, cross-platform bash hook.

Related

Metadata

Metadata

Assignees

Labels

priority: mediumReal value, no hard deadline; normal backlog flow.status: readyTriaged, unblocked, and fully specified; eligible to pick up.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions