Skip to content

Commit f45c26f

Browse files
authored
Add typos tool to pre-commit (#1144)
This tool corrects common misspellings in all kinds of text files.
1 parent 3279857 commit f45c26f

File tree

10 files changed

+34
-12
lines changed

10 files changed

+34
-12
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
]

docs/cache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ as memcached, in an InnoDB table the keys are stored in order so range scans
299299
are easy.
300300

301301
To use these methods, it must be possible to reverse-map the "full" key stored
302-
in the databse to the key you would provide to ``cache.get``, via a 'reverse
302+
in the database to the key you would provide to ``cache.get``, via a 'reverse
303303
key function'. If you have not set ``KEY_FUNCTION``, ``MySQLCache`` will use
304304
Django’s default key function, and can therefore default the reverse key
305305
function too, so you will not need to add anything.

docs/changelog.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ Changelog
507507
1.0.2 (2016-01-24)
508508
------------------
509509

510-
* New function ``add_QuerySetMixin`` allows addding the ``QuerySetMixin`` to
510+
* New function ``add_QuerySetMixin`` allows adding the ``QuerySetMixin`` to
511511
arbitrary ``QuerySet``\s, for when you can't edit a model class.
512512
* Added field class ``EnumField`` that uses MySQL's ``ENUM`` data type.
513513

@@ -650,7 +650,7 @@ Changelog
650650
0.1.5 (2015-03-11)
651651
------------------
652652

653-
* Added ``manage.py`` command ``dbparams`` for outputting database paramters
653+
* Added ``manage.py`` command ``dbparams`` for outputting database parameters
654654
in formats useful for shell scripts
655655

656656

docs/queryset_extensions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Approximate Counting
5050

5151
.. attribute:: return_approx_int=True
5252

53-
When ``True``, an ``int`` is not returned (excpet when falling back),
53+
When ``True``, an ``int`` is not returned (except when falling back),
5454
but instead a subclass called ``ApproximateInt``. This is for all
5555
intents and purposes an ``int``, apart from when cast to ``str``, it
5656
renders as e.g. **'Approximately 12345'** (internationalization

src/django_mysql/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def validate_key(self, key: str) -> None:
467467
"""
468468
if len(key) > 250:
469469
raise ValueError(
470-
f"Cache key is longer than the maxmimum 250 characters: {key}"
470+
f"Cache key is longer than the maximum 250 characters: {key}"
471471
)
472472
return super().validate_key(key)
473473

src/django_mysql/locks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(
2424
else:
2525
self.db = using
2626

27-
# For multi-database servers, we prefix the name of the lock wth
27+
# For multi-database servers, we prefix the name of the lock with
2828
# the database, to protect against concurrent apps with the same locks
2929
self.name = self.make_name(self.db, name)
3030

tests/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
DEBUG = False
77
TEMPLATE_DEBUG = DEBUG
88

9-
SECRET_KEY = "THISuISdNOT9A$SECRET9x&ji!vceayg+wwt472!bgs$0!i3k4"
9+
SECRET_KEY = "THISuISdNOT9A$SECRET9x&ji!vceayg+wwt472!bgs$0!i3k4" # typos: ignore
1010

1111
DATABASES = {
1212
"default": {

tests/testapp/test_aggregates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def test_separator_ansi_mode(self):
142142

143143
def test_ordering_invalid(self):
144144
with pytest.raises(ValueError) as excinfo:
145-
self.shakes.tutees.aggregate(tids=GroupConcat("id", ordering="asceding"))
145+
self.shakes.tutees.aggregate(tids=GroupConcat("id", ordering="unknown"))
146146
assert "'ordering' must be one of" in str(excinfo.value)
147147

148148
def test_ordering_asc(self):

tests/testapp/test_rewrite_query.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_straight_join(self):
5050
+ "nothing() AND (1)"
5151
)
5252

53-
def test_straight_join_preceeding_whitespace(self):
53+
def test_straight_join_preceding_whitespace(self):
5454
assert rewrite_query(
5555
" SELECT col_a, col_b FROM sometable WHERE nothing() AND "
5656
+ "(/*QueryRewrite':STRAIGHT_JOIN*/1)"
@@ -238,9 +238,9 @@ def test_index_hint_with_alias(self):
238238

239239
def test_index_hint_multiple_indexes(self):
240240
assert rewrite_query(
241-
"SELECT col_a FROM `tabl` WHERE "
242-
"(/*QueryRewrite':index=`tabl` IGNORE `idx1`,`idx2`*/1)"
243-
) == ("SELECT col_a FROM `tabl` IGNORE INDEX (`idx1`,`idx2`) WHERE " + "(1)")
241+
"SELECT col_a FROM `table` WHERE "
242+
"(/*QueryRewrite':index=`table` IGNORE `idx1`,`idx2`*/1)"
243+
) == ("SELECT col_a FROM `table` IGNORE INDEX (`idx1`,`idx2`) WHERE " + "(1)")
244244

245245
def test_index_hint_multiple_hints(self):
246246
assert rewrite_query(

0 commit comments

Comments
 (0)