Skip to content

Commit f0fe886

Browse files
fix(sp-ruff-checks): base indendation on max size (#694)
* fix(sp-ruff-checks): base indendation on max size Signed-off-by: Henry Schreiner <[email protected]> * style: pre-commit fixes --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 040c5c0 commit f0fe886

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

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: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,30 @@
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+
{
24+
"rule": "S101",
25+
"family": "S",
26+
"reason": "Assert is used by mypy and pytest"
27+
},
2428
{ "family": "D", "reason": "Too many doc requests" },
2529
{ "family": "TD", "reason": "Todo format" },
2630
{ "family": "FIX", "reason": "Hacks and todos" },
2731
{ "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" },
32+
{
33+
"rule": "COM812",
34+
"family": "COM",
35+
"reason": "Trailing commas teach the formatter"
36+
},
37+
{
38+
"rule": "A002",
39+
"family": "A",
40+
"reason": "Okay for arguments to shadow builtins"
41+
},
42+
{
43+
"rule": "A003",
44+
"family": "A",
45+
"reason": "Okay for attributes to shadow builtins"
46+
},
3047
{ "rule": "E501", "family": "E", "reason": "Line too long" },
3148
{ "family": "C90", "reason": "Complexity" },
3249
{

0 commit comments

Comments
 (0)