Skip to content

Commit

Permalink
Update and rename ruff_exclude.py to tool_ruff_lint_select.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss authored Oct 22, 2024
1 parent ea85e17 commit c6e6acd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions scripts/ruff_exclude.py → scripts/tool_ruff_lint_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# ruff: noqa: T201

"""Usage: ruff check --select=ALL --statistics | ./ruff_exclude.py ."""
"""Usage: ruff check --select=ALL --statistics | ./which_ruff_rules.py ."""

from __future__ import annotations

Expand All @@ -11,17 +11,19 @@
from sys import stdin


def quoted(s: str) -> str:
"""Return a double-quoted string.
def quoted(s: str, trailing: str = ",") -> str:
"""Return a double-quoted string followed by a comma.
>>> quoted("s")
>>> quoted("s", "")
'"s"'
>>> quoted('s')
>>> quoted('s', '')
'"s"'
>>> quoted(None)
'"None"'
>>> quoted('s')
'"s",'
>>> quoted(None, "!!!")
'"None"!!!'
"""
return f'"{s}"'
return f'"{s}"{trailing}'


def ruff_linters() -> dict[str, str]:
Expand Down Expand Up @@ -49,9 +51,9 @@ def ruff_linters() -> dict[str, str]:
if __name__ == "__main__":
violations = {line.split()[1].rstrip(digits) for line in stdin}
lines = [
f' {"#" if key in violations else " "} {quoted(key):<7} # {value}'
f' {"#" if key in violations else " "} {quoted(key):<8} # {value}'
for key, value in ruff_linters().items()
]
print("[tools.ruff.lint]\nexclude = [")
print("[tool.ruff]\nlint.select = [")
print("\n".join(sorted(lines)))
print("]")

0 comments on commit c6e6acd

Please sign in to comment.