Skip to content

Commit 293530f

Browse files
authored
Add typos tool to pre-commit (#1003)
This tool corrects common misspellings in all kinds of text files.
1 parent 9c29759 commit 293530f

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ repos:
1616
- id: check-toml
1717
- id: end-of-file-fixer
1818
- id: trailing-whitespace
19+
- repo: https://github.com/crate-ci/typos
20+
rev: 6cb49915af2e93e61f5f0d0a82216e28ad5c7c18 # frozen: v1
21+
hooks:
22+
- id: typos
23+
exclude: |
24+
(?x)^(
25+
.*\.min\.css
26+
|.*\.min\.js
27+
|.*\.css\.map
28+
|.*\.js\.map
29+
|.*\.svg
30+
)$
1931
- repo: https://github.com/tox-dev/pyproject-fmt
2032
rev: 57b6ff7bf72affdd12c7f3fd6de761ba18a33b3a # frozen: v2.5.1
2133
hooks:

.typos.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Configuration file for 'typos' tool
2+
# https://github.com/crate-ci/typos
3+
4+
[default]
5+
extend-ignore-re = [
6+
# Single line ignore comments
7+
"(?Rm)^.*(#|//)\\s*typos: ignore$",
8+
# Multi-line ignore comments
9+
"(?s)(#|//)\\s*typos: off.*?\\n\\s*(#|//)\\s*typos: on"
10+
]
11+
12+
[default.extend-words]
13+
Yiu = "Yiu"

tests/test_middleware.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from corsheaders.middleware import ACCESS_CONTROL_EXPOSE_HEADERS
1616
from corsheaders.middleware import ACCESS_CONTROL_MAX_AGE
1717
from tests.utils import prepend_middleware
18-
from tests.utils import temporary_check_request_hander
18+
from tests.utils import temporary_check_request_handler
1919

2020

2121
class ShortCircuitMiddleware(MiddlewareMixin):
@@ -333,7 +333,7 @@ def test_signal_handler_that_returns_false(self):
333333
def handler(*args, **kwargs):
334334
return False
335335

336-
with temporary_check_request_hander(handler):
336+
with temporary_check_request_handler(handler):
337337
resp = self.client.options(
338338
"/",
339339
headers={
@@ -349,7 +349,7 @@ def test_signal_handler_that_returns_true(self):
349349
def handler(*args, **kwargs):
350350
return True
351351

352-
with temporary_check_request_hander(handler):
352+
with temporary_check_request_handler(handler):
353353
resp = self.client.options(
354354
"/",
355355
headers={
@@ -365,7 +365,7 @@ def test_signal_handler_allow_some_urls_to_everyone(self):
365365
def allow_api_to_all(sender, request, **kwargs):
366366
return request.path.startswith("/api/")
367367

368-
with temporary_check_request_hander(allow_api_to_all):
368+
with temporary_check_request_handler(allow_api_to_all):
369369
resp = self.client.options(
370370
"/",
371371
headers={
@@ -395,7 +395,7 @@ def allow_all(sender, request, **kwargs):
395395
calls += 1
396396
return True
397397

398-
with temporary_check_request_hander(allow_all):
398+
with temporary_check_request_handler(allow_all):
399399
self.client.get("/", headers={"origin": "https://example.org"})
400400

401401
assert calls == 1

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def prepend_middleware(path: str) -> modify_settings:
1818

1919

2020
@contextmanager
21-
def temporary_check_request_hander(handler: Callable[..., bool]) -> Generator[None]:
21+
def temporary_check_request_handler(handler: Callable[..., bool]) -> Generator[None]:
2222
check_request_enabled.connect(handler)
2323
try:
2424
yield

0 commit comments

Comments
 (0)