1 """Simple script for rebuilding .codespell-ignore-lines
5 cat < /dev/null > .codespell-ignore-lines
6 pre-commit run --all-files codespell >& /tmp/codespell_errors.txt
7 python3 tools/codespell_ignore_lines_from_errors.py /tmp/codespell_errors.txt > .codespell-ignore-lines
9 git diff to review changes, then commit, push.
12 from __future__
import annotations
17 def run(args: list[str]) ->
None:
18 assert len(args) == 1,
"codespell_errors.txt"
21 with open(args[0])
as f:
22 lines = f.read().splitlines()
24 for line
in sorted(lines):
25 i = line.find(
" ==> ")
27 flds = line[:i].
split(
":")
29 filename, line_num = flds[:2]
30 if filename
not in cache:
31 with open(filename)
as f:
32 cache[filename] = f.read().splitlines()
33 supp = cache[filename][
int(line_num) - 1]
39 if __name__ ==
"__main__":
40 run(args=sys.argv[1:])