Skip to content

Commit a36732b

Browse files
committed
fix(sp-ruff-checks): base indendation on max size
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
1 parent c64d08f commit a36732b

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/sp_repo_review/ruff_checks/__main__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import importlib.resources
33
import json
44
import sys
5-
from collections.abc import Iterator
5+
from collections.abc import Iterator, Mapping
66
from pathlib import Path
77

88
from rich import print
@@ -29,10 +29,11 @@
2929
IGNORE_INFO = json.load(f)
3030

3131

32-
def print_each(items: dict[str, str]) -> Iterator[str]:
32+
def print_each(items: Mapping[str, str]) -> Iterator[str]:
33+
size = max(len(k) for k in items) if items else 0
3334
for k, v in items.items():
3435
kk = f'[green]"{k}"[/green],'
35-
yield f" {kk:23} [dim]# {v}[/dim]"
36+
yield f" {kk:{size + 18}} [dim]# {v}[/dim]"
3637

3738

3839
def process_dir(path: Path) -> None:

src/sp_repo_review/ruff_checks/ignore.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
"rule": "RUF009",
2121
"reason": "Too easy to get a false positive (function call in dataclass defaults)"
2222
},
23-
{ "family": "S", "reason": "Some subset is okay" },
23+
{ "rule": "S101", "family": "S", "reason": "Assert is used by mypy and pytest" },
2424
{ "family": "D", "reason": "Too many doc requests" },
2525
{ "family": "TD", "reason": "Todo format" },
2626
{ "family": "FIX", "reason": "Hacks and todos" },
2727
{ "rule": "TID252", "family": "TID", "reason": "Relative imports are fine" },
28-
{ "family": "COM", "reason": "Trailing commas teach the formatter" },
29-
{ "family": "A", "reason": "Okay to shadow builtins" },
28+
{ "rule": "COM812", "family": "COM", "reason": "Trailing commas teach the formatter" },
29+
{ "rule": "A002", "family": "A", "reason": "Okay for arguments to shadow builtins" },
30+
{ "rule": "A003", "family": "A", "reason": "Okay for attributes to shadow builtins" },
3031
{ "rule": "E501", "family": "E", "reason": "Line too long" },
3132
{ "family": "C90", "reason": "Complexity" },
3233
{

0 commit comments

Comments
 (0)