mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-23 13:45:10 +00:00
8756f16ed8
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/Lucas-C/pre-commit-hooks: v1.3.0 → v1.3.1](https://github.com/Lucas-C/pre-commit-hooks/compare/v1.3.0...v1.3.1) - [github.com/sirosen/texthooks: 0.3.1 → 0.4.0](https://github.com/sirosen/texthooks/compare/0.3.1...0.4.0) - [github.com/PyCQA/pylint: v2.14.5 → v2.15.0](https://github.com/PyCQA/pylint/compare/v2.14.5...v2.15.0) - [github.com/codespell-project/codespell: v2.1.0 → v2.2.1](https://github.com/codespell-project/codespell/compare/v2.1.0...v2.2.1) * Introduce .codespell-ignore-lines for safer (line-based instead of word-based) suppressions. * Fix two issues: 1. ensure sort order; 2. remove duplicates Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
"""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:])
|