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.
13 from typing
import List
16 def run(args: List[str]) ->
None:
17 assert len(args) == 1,
"codespell_errors.txt"
20 with open(args[0])
as f:
21 lines = f.read().splitlines()
23 for line
in sorted(lines):
24 i = line.find(
" ==> ")
26 flds = line[:i].
split(
":")
28 filename, line_num = flds[:2]
29 if filename
not in cache:
30 with open(filename)
as f:
31 cache[filename] = f.read().splitlines()
32 supp = cache[filename][
int(line_num) - 1]
38 if __name__ ==
"__main__":
39 run(args=sys.argv[1:])