aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/pybind11/tools/codespell_ignore_lines_from_errors.py
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/pybind11/tools/codespell_ignore_lines_from_errors.py')
-rw-r--r--3rdparty/pybind11/tools/codespell_ignore_lines_from_errors.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/3rdparty/pybind11/tools/codespell_ignore_lines_from_errors.py b/3rdparty/pybind11/tools/codespell_ignore_lines_from_errors.py
new file mode 100644
index 00000000..5403ec3a
--- /dev/null
+++ b/3rdparty/pybind11/tools/codespell_ignore_lines_from_errors.py
@@ -0,0 +1,35 @@
+"""Simple script for rebuilding .codespell-ignore-lines
+
+Usage:
+
+cat < /dev/null > .codespell-ignore-lines
+pre-commit run --all-files codespell >& /tmp/codespell_errors.txt
+python3 tools/codespell_ignore_lines_from_errors.py /tmp/codespell_errors.txt > .codespell-ignore-lines
+
+git diff to review changes, then commit, push.
+"""
+
+import sys
+from typing import List
+
+
+def run(args: List[str]) -> None:
+ assert len(args) == 1, "codespell_errors.txt"
+ cache = {}
+ done = set()
+ for line in sorted(open(args[0]).read().splitlines()):
+ i = line.find(" ==> ")
+ if i > 0:
+ flds = line[:i].split(":")
+ if len(flds) >= 2:
+ filename, line_num = flds[:2]
+ if filename not in cache:
+ cache[filename] = open(filename).read().splitlines()
+ supp = cache[filename][int(line_num) - 1]
+ if supp not in done:
+ print(supp)
+ done.add(supp)
+
+
+if __name__ == "__main__":
+ run(args=sys.argv[1:])