Skip to content

Commit 61e261c

Browse files
Introduced typos pre-commit hook. (#490)
Introduced `typos` pre-commit hook. _typos.toml is used to discard false positives in email headers: error: `Forr` should be `For` --> tests/data/spec_no_trailing_newline/patch0.patch:2:26 | 2 | From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <[email protected]> | ^^^^ On the subject of pre-commit hooks, might I suggest removing https://github.com/pre-commit/mirrors-prettier? pre-commit/mirrors-prettier was actually archived back in Apr 11, 2024. Further, on my Rocky8 machine, with both Python 3.9 and 3.12, it kept on failing to retrieve the nodejs tar it claimed to need: $ git commit -a [INFO] Installing environment for https://github.com/pre-commit/mirrors-prettier. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/python3.12', '-mnodeenv', '--prebuilt', '--clean-src', '/home/jesse/.cache/pre-commit/repo1a7gxoya/node_env-default') return code: 1 stdout: (none) stderr: * Install prebuilt node (24.8.0) .Incomplete read while reading from https://nodejs.org/download/release/v24.8.0/node-v24.8.0-linux-x64.tar.gz - IncompleteRead(54483458 bytes read, 4401371 more expected) Incomplete read while reading from https://nodejs.org/download/release/v24.8.0/node-v24.8.0-linux-x64.tar.gz - IncompleteRead(54417858 bytes read, 4466971 more expected) Incomplete read while reading from https://nodejs.org/download/release/v24.8.0/node-v24.8.0-linux-x64.tar.gz - IncompleteRead(56590530 bytes read, 2294299 more expected) Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/home/jesse/.local/lib/python3.12/site-packages/nodeenv.py", line 1548, in <module> main() File "/home/jesse/.local/lib/python3.12/site-packages/nodeenv.py", line 1130, in main create_environment(env_dir, args) File "/home/jesse/.local/lib/python3.12/site-packages/nodeenv.py", line 1006, in create_environment install_node(env_dir, src_dir, args) File "/home/jesse/.local/lib/python3.12/site-packages/nodeenv.py", line 763, in install_node install_node_wrapped(env_dir, src_dir, args) File "/home/jesse/.local/lib/python3.12/site-packages/nodeenv.py", line 786, in install_node_wrapped download_node_src(node_url, src_dir, args) File "/home/jesse/.local/lib/python3.12/site-packages/nodeenv.py", line 618, in download_node_src dl_contents = _download_node_file(node_url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jesse/.local/lib/python3.12/site-packages/nodeenv.py", line 610, in _download_node_file raise e File "/home/jesse/.local/lib/python3.12/site-packages/nodeenv.py", line 602, in _download_node_file return io.BytesIO(urlopen(node_url).read()) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/http/client.py", line 495, in read s = self._safe_read(self.length) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/http/client.py", line 644, in _safe_read raise IncompleteRead(data, amt-len(data)) http.client.IncompleteRead: IncompleteRead(56590530 bytes read, 2294299 more expected) On my Debian GNU/Linux 13 (trixie) machine: $ python --version Python 3.13.5 $ git commit -a [INFO] Installing environment for https://github.com/pre-commit/mirrors-prettier. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/python3', '-mnodeenv', '--prebuilt', '--clean-src', '/home/jesse/.cache/pre-commit/repojzxdfadf/node_env-default') return code: 1 stdout: (none) stderr: /usr/lib/python3/dist-packages/nodeenv.py:759: SyntaxWarning: invalid escape sequence '\d' VERSION_RE = re.compile('\d+\.\d+\.\d+') /usr/lib/python3/dist-packages/nodeenv.py:960: SyntaxWarning: invalid escape sequence '\.' local re="[a-zA-Z0-9\.\-]+@[0-9]+\.[0-9]+\.[0-9]+([\+\-][a-zA-Z0-9\.\-]+)*" Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/lib/python3/dist-packages/nodeenv.py", line 24, in <module> import pipes ModuleNotFoundError: No module named 'pipes' Considering that this code base is basically pure Python and we use: - repo: https://github.com/psf/black rev: 25.1.0 hooks: - id: black I'm not sure what value pre-commit/mirrors-prettier actually adds but if there's something it checks the other hooks do not address, I'd recommend finding a maintained alternative. Reviewed-by: gemini-code-assist[bot] Reviewed-by: Jesse Portnoy <[email protected]> Reviewed-by: Nikola Forró
2 parents 87d0521 + 02f922e commit 61e261c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,8 @@ repos:
8484
- LICENSE_HEADER.txt
8585
- --comment-style
8686
- "#"
87+
- repo: https://github.com/crate-ci/typos
88+
rev: v1.36.2
89+
hooks:
90+
- id: typos
91+
args: [--config, _typos.toml]

_typos.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[default]
2+
extend-ignore-re = [
3+
"From:.*=\\?UTF-8\\?q\\?.*", # Ignore encoded email headers
4+
]
5+
6+
# Allow these as valid words
7+
extend-words = { SOURCEN = "SOURCEN" }

0 commit comments

Comments
 (0)