Skip to content

Commit 4db8f6e

Browse files
authored
ci: add codespell pre-commit hook (#1899)
This PR adds a [`codespell`](https://github.com/codespell-project/codespell) pre-commit hook (see PRs #1583 / #1611 / #1898). With this PR, if you run `pre-commit run --all-files` on the current state of the repo, you will see: ``` trim trailing whitespace.................................................Passed check python ast.........................................................Passed check for merge conflicts................................................Passed don't commit to branch...................................................Passed check for added large files..............................................Passed fix end of files.........................................................Passed Insert license in comments...............................................Passed flake8...................................................................Passed Format files with µfmt...................................................Passed pydoclint................................................................Passed codespell................................................................Failed - hook id: codespell - exit code: 65 torchtitan/models/utils.py:51: caculate ==> calculate torchtitan/models/utils.py:71: Calulate ==> Calculate torchtitan/models/utils.py:71: dimesion ==> dimension torchtitan/models/utils.py:71: demension ==> dimension torchtitan/models/utils.py:76: divded ==> divided torchtitan/experiments/vlm/job_config.py:28: avaliable ==> available torchtitan/experiments/vlm/README.md:37: patchs ==> patches, paths torchtitan/experiments/vlm/README.md:40: indicies ==> indices torchtitan/components/quantization/__init__.py:28: re-usable ==> reusable torchtitan/models/qwen3/model/state_dict_adapter.py:144: compatibile ==> compatible torchtitan/models/attention.py:185: argumens ==> arguments torchtitan/components/metrics.py:322: emtpy ==> empty docs/torchft.md:60: sychronize ==> synchronize torchtitan/experiments/simple_fsdp/README.md:56: addtional ==> additional ``` After PR #1898 is merged, those warnings will disappear. Configuration for codespell is in `pyproject.toml`: ``` skip = ["*.json"] # <- json files are skipped due to too many false positives ignore-words-list = ["assertin", "datas" ,"indx", "inpt", "nd", "socio-economic"] # <- words that are ignored because they are used as variables etc.
1 parent f7a56e6 commit 4db8f6e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,15 @@ repos:
4949
hooks:
5050
- id: pydoclint
5151
args: [--config=pyproject.toml]
52+
53+
- repo: https://github.com/codespell-project/codespell
54+
rev: v2.4.1
55+
hooks:
56+
- id: codespell
57+
name: codespell
58+
description: Checks for common misspellings in text files.
59+
entry: codespell --toml pyproject.toml
60+
language: python
61+
types: [text]
62+
additional_dependencies:
63+
- tomli

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ dev = [
4343
[tool.setuptools.dynamic]
4444
version = {file = "assets/version.txt"}
4545

46+
[tool.codespell]
47+
skip = ["*.json"]
48+
ignore-words-list = ["assertin", "datas" ,"indx", "inpt", "nd", "socio-economic"]
4649

4750
# ---- Explicit project build information ---- #
4851
[build-system]

0 commit comments

Comments
 (0)