Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Feedback: Sort additional .wordlist files, too
  • Loading branch information
kurtmckee committed Jul 27, 2023
commit 732d0b9c41ca6737fb7a7a86da2c9bbe8acabc51
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
files: ^(.*\.(py|json|md|sh|yaml|yml|in|cfg|txt|rst|toml|precommit-toml))$
files: ^(.*\.(py|json|md|sh|yaml|yml|in|cfg|txt|rst|toml|precommit-toml|wordlist))$
exclude: ^(\.[^/]*cache/.*)$
repos:
- repo: https://github.com/executablebooks/mdformat
Expand Down Expand Up @@ -47,7 +47,7 @@ repos:
- id: check-case-conflict
- id: check-toml
- id: file-contents-sorter
files: dictionary.*\.txt$
files: dictionary.*\.txt$|\.wordlist$
args: [--ignore-case]
Comment thread
kurtmckee marked this conversation as resolved.
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DICTIONARIES := codespell_lib/data/dictionary*.txt
DICTIONARIES := codespell_lib/data/dictionary*.txt codespell_lib/tests/data/*.wordlist

PHONY := all check check-dictionaries sort-dictionaries trim-dictionaries check-dist pytest pypi ruff clean

Expand Down
22 changes: 14 additions & 8 deletions codespell_lib/tests/test_dictionary.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import glob
import os
import os.path as op
import pathlib
import re
import warnings
from typing import Any, Dict, Iterable, Optional, Set, Tuple
Expand All @@ -11,6 +12,8 @@

spellers = {}

root = pathlib.Path(__file__).parent.parent

try:
import aspell # type: ignore[import]

Expand Down Expand Up @@ -77,18 +80,21 @@ def test_dictionary_formatting(
raise AssertionError("\n" + "\n".join(errors))


@fname_params
def test_dictionary_sorting(
fname: str,
in_aspell: Tuple[bool, bool],
in_dictionary: Tuple[Iterable[str], Iterable[str]],
) -> None:
@pytest.mark.parametrize(
"filename",
[
*(root / "data").rglob("dictionary*.txt"),
*(root / "tests/data").rglob("*.wordlist"),
],
)
def test_dictionary_sorting(filename: pathlib.Path) -> None:
relative_path = filename.relative_to(root)
previous_line = None
with open(fname, encoding="utf-8") as file:
with filename.open(encoding="utf-8") as file:
for current_line in file:
current_line = current_line.strip().lower()
if previous_line is not None:
assert previous_line < current_line, f"{fname} is not sorted"
assert previous_line < current_line, f"{relative_path} is not sorted"
previous_line = current_line


Expand Down