Skip to content

Commit 0950916

Browse files
[pre-commit] Add codespell, and fix some existing typos (#9912)
* Add the spellchecker codespell to the pre-commit configuration * Make the dict name generic now that it's used by multiple tools * Fix existing typos * Sort the custom dict
1 parent 3b4a7f9 commit 0950916

39 files changed

+105
-63
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ repos:
77
hooks:
88
- id: trailing-whitespace
99
exclude: tests(/\w*)*/functional/t/trailing_whitespaces.py|tests/pyreverse/data/.*.html|doc/data/messages/t/trailing-whitespace/bad.py
10+
# - id: file-contents-sorter # commented out because it does not preserve comments order
11+
# args: ["--ignore-case", "--unique"]
12+
# files: "custom_dict.txt"
1013
- id: end-of-file-fixer
1114
exclude: |
1215
(?x)^(
@@ -173,3 +176,10 @@ repos:
173176
- id: bandit
174177
args: ["-r", "-lll"]
175178
exclude: *fixtures
179+
- repo: https://github.com/codespell-project/codespell
180+
rev: v2.3.0
181+
hooks:
182+
- id: codespell
183+
args: ["--toml=pyproject.toml"]
184+
additional_dependencies:
185+
- tomli

.pyenchant_pylint_custom_dict.txt renamed to custom_dict.txt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ argumentparser
1313
argumentsparser
1414
argv
1515
ascii
16+
asend
1617
assignattr
1718
assignname
18-
ast
1919
AST
20+
ast
2021
astroid
2122
async
2223
asynccontextmanager
@@ -67,8 +68,8 @@ contextlib
6768
contextmanager
6869
contravariance
6970
contravariant
70-
cpython
7171
CPython
72+
cpython
7273
csv
7374
CVE
7475
cwd
@@ -126,8 +127,8 @@ formfeed
126127
fromlineno
127128
fullname
128129
func
129-
functiøn
130130
functiondef
131+
functiøn
131132
functools
132133
genexpr
133134
getattr
@@ -160,10 +161,11 @@ isfile
160161
isinstance
161162
isort
162163
iter
163-
itered
164164
iterable
165165
iterables
166+
itered
166167
iteritems
168+
iTerm
167169
jn
168170
jpg
169171
json
@@ -206,10 +208,10 @@ monkeypatch
206208
mro
207209
# Used so much that we need the abbreviation
208210
msg
211+
msg-template
209212
msgid
210213
msgids
211214
msgs
212-
msg-template
213215
mult
214216
multiline
215217
multiset
@@ -250,8 +252,8 @@ parens
250252
passthru
251253
pathlib
252254
patternerror
253-
positionals
254255
png
256+
positionals
255257
pragma
256258
pragma's
257259
pragmas
@@ -264,9 +266,9 @@ pyenchant
264266
pyfile
265267
pyi
266268
pylint
269+
pylint's
267270
pylintdict
268271
pylintrc
269-
pylint's
270272
pyproject
271273
pypy
272274
pyreverse
@@ -275,6 +277,7 @@ qname
275277
rawcheckers
276278
rc
277279
rcfile
280+
re-usable
278281
readlines
279282
recognise
280283
recurse
@@ -345,9 +348,9 @@ tomlkit
345348
toplevel
346349
towncrier
347350
tp
351+
truthey
348352
truthness
349353
truthy
350-
truthey
351354
tryexcept
352355
txt
353356
typecheck
@@ -362,8 +365,8 @@ unary
362365
unflattens
363366
unhandled
364367
unicode
365-
Uninferable
366368
uninferable
369+
Uninferable
367370
unittest
368371
unraisablehook
369372
untriggered

doc/development_guide/contributor_guide/profiling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ and thus is displayed as being 0.
9090

9191
Often you are more interested in the cumulative time (per call). This refers to the time spent within the function
9292
and any of the functions it called or the functions they called (etc.). In our example, the ``visit_importfrom``
93-
method and all of its child-functions took a little over 8 seconds to exectute, with an execution time of
93+
method and all of its child-functions took a little over 8 seconds to execute, with an execution time of
9494
0.013 ms per call.
9595

9696
You can also search the ``profiler_stats`` for an individual function you want to check. For example

doc/development_guide/contributor_guide/tests/writing_test.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Unittest tests
2121

2222
Most other tests reside in the '/pylint/test' directory. These unittests can be used to test
2323
almost all functionality within Pylint. A good step before writing any new unittests is to look
24-
at some tests that test a similar funcitionality. This can often help write new tests.
24+
at some tests that test a similar functionality. This can often help write new tests.
2525

2626
If your new test requires any additional files you can put those in the
2727
``/pylint/test/regrtest_data`` directory. This is the directory we use to store any data needed for

doc/user_guide/checkers/features.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -918,16 +918,16 @@ Refactoring checker Messages
918918
Emitted when a single "return" or "return None" statement is found at the end
919919
of function or method definition. This statement can safely be removed
920920
because Python will implicitly return None
921-
:use-implicit-booleaness-not-comparison-to-string (C1804): *"%s" can be simplified to "%s", if it is striclty a string, as an empty string is falsey*
922-
Empty string are considered false in a boolean context. Following this check
923-
blindly in weakly typed code base can create hard to debug issues. If the
924-
value can be something else that is falsey but not a string (for example
925-
``None``, an empty sequence, or ``0``) the code will not be equivalent.
926921
:use-implicit-booleaness-not-comparison (C1803): *"%s" can be simplified to "%s", if it is strictly a sequence, as an empty %s is falsey*
927922
Empty sequences are considered false in a boolean context. Following this
928923
check blindly in weakly typed code base can create hard to debug issues. If
929924
the value can be something else that is falsey but not a sequence (for
930925
example ``None``, an empty string, or ``0``) the code will not be equivalent.
926+
:use-implicit-booleaness-not-comparison-to-string (C1804): *"%s" can be simplified to "%s", if it is strictly a string, as an empty string is falsey*
927+
Empty string are considered false in a boolean context. Following this check
928+
blindly in weakly typed code base can create hard to debug issues. If the
929+
value can be something else that is falsey but not a string (for example
930+
``None``, an empty sequence, or ``0``) the code will not be equivalent.
931931
:use-implicit-booleaness-not-comparison-to-zero (C1805): *"%s" can be simplified to "%s", if it is strictly an int, as 0 is falsey*
932932
0 is considered false in a boolean context. Following this check blindly in
933933
weakly typed code base can create hard to debug issues. If the value can be

doc/whatsnew/0/0.x.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ Release date: 2004-10-19
10011001
* avoid importing analyzed modules !
10021002

10031003
* new Refactor and Convention message categories. Some Warnings have been
1004-
remaped into those new categories
1004+
remapped into those new categories
10051005

10061006
* added "similar", a tool to find copied and pasted lines of code,
10071007
both using a specific command line tool and integrated as a

doc/whatsnew/1/1.5.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ Release date: 2015-11-29
435435
* astroid.utils.LocalsVisitor was moved to pylint.pyreverse.LocalsVisitor.
436436

437437
* pylint.checkers.utils.excepts_import_error was removed.
438-
Use pylint.chekcers.utils.error_of_type instead.
438+
Use pylint.checkers.utils.error_of_type instead.
439439

440440
* Don't emit undefined-all-variables for nodes which can't be
441441
inferred (YES nodes).

doc/whatsnew/2/2.0/summary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Other Changes
221221
``pylint`` should be a bit faster as well.
222222

223223
We added a new flag, ``max_inferable_values`` on ``astroid.MANAGER`` for
224-
limitting the maximum amount of values that ``astroid`` can infer when inferring
224+
limiting the maximum amount of values that ``astroid`` can infer when inferring
225225
values. This change should improve the performance when dealing with large frameworks
226226
such as ``django``.
227227
You can also control this behaviour with ``pylint --limit-inference-results``

doc/whatsnew/2/2.13/summary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ New checkers
8181
creates memory leaks by never letting the instance get garbage collected.
8282

8383
Closes #5670
84-
Clsoes #6180
84+
Closes #6180
8585

8686
Removed checkers
8787
================

doc/whatsnew/2/2.4/full.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Release date: 2019-09-24
137137
Closes #2925
138138

139139
* ``useless-suppression`` check now ignores ``cyclic-import`` suppressions,
140-
which could lead to false postiives due to incomplete context at the time
140+
which could lead to false positives due to incomplete context at the time
141141
of the check.
142142

143143
Closes #3064

doc/whatsnew/2/2.6/full.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Release date: 2020-08-20
5454

5555
* Add ``raise-missing-from`` check for exceptions that should have a cause.
5656

57-
* Support both isort 4 and isort 5. If you have pinned isort 4 in your projet requirements, nothing changes. If you use isort 5, though, note that the ``known-standard-library`` option is not interpreted the same in isort 4 and isort 5 (see the migration guide in isort documentation for further details). For compatibility's sake for most pylint users, the ``known-standard-library`` option in pylint now maps to ``extra-standard-library`` in isort 5. If you really want what ``known-standard-library`` now means in isort 5, you must disable the ``wrong-import-order`` check in pylint and run isort manually with a proper isort configuration file.
57+
* Support both isort 4 and isort 5. If you have pinned isort 4 in your project requirements, nothing changes. If you use isort 5, though, note that the ``known-standard-library`` option is not interpreted the same in isort 4 and isort 5 (see the migration guide in isort documentation for further details). For compatibility's sake for most pylint users, the ``known-standard-library`` option in pylint now maps to ``extra-standard-library`` in isort 5. If you really want what ``known-standard-library`` now means in isort 5, you must disable the ``wrong-import-order`` check in pylint and run isort manually with a proper isort configuration file.
5858

5959
Closes #3722
6060

doc/whatsnew/2/2.6/summary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ Other Changes
2525

2626
* Fix superfluous-parens false-positive for the walrus operator
2727

28-
* Add support for both isort 4 and isort 5. If you have pinned isort 4 in your projet requirements, nothing changes. If you use isort 5, though, note that the ``known-standard-library`` option is not interpreted the same in isort 4 and isort 5 (see `the migration guide in isort documentation` (no longer available) for further details). For compatibility's sake for most pylint users, the ``known-standard-library`` option in pylint now maps to ``extra-standard-library`` in isort 5. If you really want what ``known-standard-library`` now means in isort 5, you must disable the ``wrong-import-order`` check in pylint and run isort manually with a proper isort configuration file.
28+
* Add support for both isort 4 and isort 5. If you have pinned isort 4 in your project requirements, nothing changes. If you use isort 5, though, note that the ``known-standard-library`` option is not interpreted the same in isort 4 and isort 5 (see `the migration guide in isort documentation` (no longer available) for further details). For compatibility's sake for most pylint users, the ``known-standard-library`` option in pylint now maps to ``extra-standard-library`` in isort 5. If you really want what ``known-standard-library`` now means in isort 5, you must disable the ``wrong-import-order`` check in pylint and run isort manually with a proper isort configuration file.

doc/whatsnew/3/3.1/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Other Bug Fixes
118118
The message will report imports as follows:
119119
For "import X", it will report "(standard/third party/first party/local) import X"
120120
For "import X.Y" and "from X import Y", it will report "(standard/third party/first party/local) import X.Y"
121-
The import category is specified to provide explanation as to why pylint has issued the message and guidence to the developer on how to fix the problem.
121+
The import category is specified to provide explanation as to why pylint has issued the message and guidance to the developer on how to fix the problem.
122122

123123
Closes #8808 (`#8808 <https://github.com/pylint-dev/pylint/issues/8808>`_)
124124

pylint/checkers/base/function_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def _check_contextmanager_generator_missing_cleanup(
4545
:param node: FunctionDef node to check
4646
:type node: nodes.FunctionDef
4747
"""
48-
# if function does not use a Yield statement, it cant be a generator
48+
# if function does not use a Yield statement, it can't be a generator
4949
with_nodes = list(node.nodes_of_class(nodes.With))
5050
if not with_nodes:
5151
return

pylint/checkers/refactoring/implicit_booleaness_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ImplicitBooleanessChecker(checkers.BaseChecker):
8181
"equivalent.",
8282
),
8383
"C1804": (
84-
'"%s" can be simplified to "%s", if it is striclty a string, as an empty string is falsey',
84+
'"%s" can be simplified to "%s", if it is strictly a string, as an empty string is falsey',
8585
"use-implicit-booleaness-not-comparison-to-string",
8686
"Empty string are considered false in a boolean context. Following this"
8787
" check blindly in weakly typed code base can create hard to debug issues."

pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ spelling-ignore-words=
400400
spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy:,pragma:,# noinspection
401401

402402
# A path to a file that contains private dictionary; one word per line.
403-
spelling-private-dict-file=.pyenchant_pylint_custom_dict.txt
403+
spelling-private-dict-file=custom_dict.txt
404404

405405
# Tells whether to store unknown words to indicated private dictionary in
406406
# --spelling-private-dict-file option instead of raising a message.

pyproject.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,32 @@ ignore = [
200200

201201
[tool.ruff.lint.pydocstyle]
202202
convention = "pep257"
203+
204+
[tool.codespell]
205+
ignore-words = ["custom_dict.txt"]
206+
207+
# Disabled the spelling files for obvious reason, but also,
208+
# the test file with typing extension imported as 'te' and:
209+
# tests/functional/i/implicit/implicit_str_concat_latin1.py:
210+
# - bad encoding
211+
# pylint/pyreverse/diagrams.py and tests/pyreverse/test_diagrams.py:
212+
# - An API from pyreverse use 'classe', and would need to be deprecated
213+
# pylint/checkers/imports.py:
214+
# - 'THIRDPARTY' is a value from isort that would need to be handled even
215+
# if isort fix the typo in newer versions
216+
# tests/functional/m/member/member_checks.py:
217+
# - typos are voluntary to create credible 'no-member'
218+
219+
skip = """
220+
tests/checkers/unittest_spelling.py,\
221+
CODE_OF_CONDUCT.md,\
222+
CONTRIBUTORS.txt,\
223+
pylint/checkers/imports.py,\
224+
pylint/pyreverse/diagrams.py,\
225+
tests/pyreverse/test_diagrams.py,\
226+
tests/functional/i/implicit/implicit_str_concat_latin1.py,\
227+
tests/functional/m/member/member_checks.py,\
228+
tests/functional/t/type/typevar_naming_style_rgx.py,\
229+
tests/functional/t/type/typevar_naming_style_default.py,\
230+
tests/functional/m/member/member_checks_async.py,\
231+
"""

tests/checkers/unittest_misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_xxx_without_space(self) -> None:
4040

4141
def test_xxx_middle(self) -> None:
4242
code = """a = 1
43-
# midle XXX
43+
# middle XXX
4444
"""
4545
with self.assertNoMessages():
4646
self.checker.process_tokens(_tokenize_str(code))

tests/config/functional/toml/unknown_msgid/enable_unknown_msgid.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Check the behavior for unkonwn symbol/msgid
1+
# Check the behavior for unknown symbol/msgid
22
# (Originally) reported in https://github.com/pylint-dev/pylint/pull/6293
33

44
[tool.pylint."messages control"]
File renamed without changes.

tests/functional/a/arguments_differ.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class ChildT3(ParentT3):
280280
def func(self, user_input: FooT1) -> None:
281281
pass
282282

283-
# Keyword and positional overriddes
283+
# Keyword and positional overrides
284284
class AbstractFoo:
285285

286286
def kwonly_1(self, first, *, second, third):

tests/functional/c/consider/consider_using_get.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
if 'key' in dictionary: # not accessing the dictionary in assignment
1717
variable = "string"
1818

19-
if 'key' in dictionary: # is a match, but not obvious and we ignore it for now
19+
if 'key' in dictionary: # is a match, but not obvious, and we ignore it for now
2020
variable = dictionary[key]
2121

22-
if 'key1' in dictionary: # dictionary querried for wrong key
22+
if 'key1' in dictionary: # dictionary queried for wrong key
2323
variable = dictionary['key2']
2424

2525
if 'key' in dictionary: # body is not pure
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pylint: disable=missing-module-docstring
22

33
dictionary = {'0': 0}
4-
# quotes are inconsistent when targetting Python 3.12 (use single quotes)
4+
# quotes are inconsistent when targeting Python 3.12 (use single quotes)
55
F_STRING = f'{dictionary["0"]}' # [inconsistent-quotes]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pylint: disable=missing-module-docstring
22

33
dictionary = {'0': 0}
4-
# quotes are consistent when targetting 3.11 and earlier (cannot use single quotes here)
4+
# quotes are consistent when targeting 3.11 and earlier (cannot use single quotes here)
55
F_STRING = f'{dictionary["0"]}'

tests/functional/m/misplaced_format_function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
print("value: {}").format(123) # [misplaced-format-function]
77
print('value: {}'.format(123))
88
print('{} Come Forth!'.format('Lazarus'))
9-
print('Der Hem ist mein Licht und mein Heil, vor wem sollte ich mich furchten? => {}'.format('Psalm 27, 1'))
9+
print('He is my light and my salvation, of whom should I be afraid? => {}'.format('Psalm 27, 1'))
1010
print('123')
1111
print()
1212
s = 'value: {}'.format(123)

tests/functional/n/names_in__all__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pylint: disable=too-few-public-methods, import-error, unnecessary-pass
22
"""Test Pylint's use of __all__.
33
4-
* NonExistant is not defined in this module, and it is listed in
4+
* NonExistent is not defined in this module, and it is listed in
55
__all__. An error is expected.
66
77
* This module imports path and republished it in __all__. No errors
@@ -16,7 +16,7 @@
1616
'', # [undefined-all-variable]
1717
Missing,
1818
SomeUndefined, # [undefined-variable]
19-
'NonExistant', # [undefined-all-variable]
19+
'NonExistent', # [undefined-all-variable]
2020
'path',
2121
'func', # [undefined-all-variable]
2222
'inner', # [undefined-all-variable]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
undefined-all-variable:16:4:16:6::Undefined variable name '' in __all__:UNDEFINED
22
undefined-variable:18:4:18:17::Undefined variable 'SomeUndefined':UNDEFINED
3-
undefined-all-variable:19:4:19:17::Undefined variable name 'NonExistant' in __all__:UNDEFINED
3+
undefined-all-variable:19:4:19:17::Undefined variable name 'NonExistent' in __all__:UNDEFINED
44
undefined-all-variable:21:4:21:10::Undefined variable name 'func' in __all__:UNDEFINED
55
undefined-all-variable:22:4:22:11::Undefined variable name 'inner' in __all__:UNDEFINED
66
undefined-all-variable:23:4:23:16::Undefined variable name 'InnerKlass' in __all__:UNDEFINED

tests/functional/n/no/no_name_in_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
toto.yo()
88

99
from xml.etree import ElementTree
10-
ElementTree.nonexistant_function() # [no-member]
11-
ElementTree.another.nonexistant.function() # [no-member]
10+
ElementTree.nonexistent_function() # [no-member]
11+
ElementTree.another.nonexistent.function() # [no-member]
1212

1313

1414
import sys

0 commit comments

Comments
 (0)