Skip to content

Commit 8bd8b4a

Browse files
authored
add codespell pre-commit hook (#3373)
2 parents d777956 + e3c0898 commit 8bd8b4a

11 files changed

Lines changed: 26 additions & 21 deletions

File tree

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
33
rev: c60c980e561ed3e73101667fe8365c609d19a438 # frozen: v0.15.9
44
hooks:
5-
- id: ruff
5+
- id: ruff-check
66
- id: ruff-format
77
- repo: https://github.com/astral-sh/uv-pre-commit
88
rev: 0397b68f6f88c024f1d2b355a9818779f6336d16 # frozen: 0.11.3
99
hooks:
1010
- id: uv-lock
11+
- repo: https://github.com/codespell-project/codespell
12+
rev: 2ccb47ff45ad361a21071a7eedda4c37e6ae8c5a # frozen: v2.4.2
13+
hooks:
14+
- id: codespell
15+
args: ['--write-changes', '--ignore-words-list=inout,te']
1116
- repo: https://github.com/pre-commit/pre-commit-hooks
1217
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
1318
hooks:

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ Released 2018-09-25
942942
so that changing the working directory does not affect it. :pr:`920`
943943
- Fix incorrect completions when defaults are present :issue:`925`,
944944
:pr:`930`
945-
- Add copy option attrs so that custom classes can be re-used.
945+
- Add copy option attrs so that custom classes can be reused.
946946
:issue:`926`, :pr:`994`
947947
- "x" and "a" file modes now use stdout when file is ``"-"``.
948948
:pr:`929`

examples/aliases/aliases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AliasedGroup(click.Group):
4040
"""
4141

4242
def get_command(self, ctx, cmd_name):
43-
# Step one: bulitin commands as normal
43+
# Step one: built-in commands as normal
4444
rv = click.Group.get_command(self, ctx, cmd_name)
4545
if rv is not None:
4646
return rv

examples/repo/repo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def cli(ctx, repo_home, config, verbose):
4848
This tool is supposed to look like a distributed version control
4949
system to show how something like this can be structured.
5050
"""
51-
# Create a repo object and remember it as as the context object. From
51+
# Create a repo object and remember it as the context object. From
5252
# this point onwards other commands can refer to it by using the
5353
# @pass_repo decorator.
5454
ctx.obj = Repo(os.path.abspath(repo_home))

src/click/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class Context:
196196
:param info_name: the info name for this invocation. Generally this
197197
is the most descriptive name for the script or
198198
command. For the toplevel script it is usually
199-
the name of the script, for commands below it it's
199+
the name of the script, for commands below that it's
200200
the name of the script.
201201
:param obj: an arbitrary object of user data.
202202
:param auto_envvar_prefix: the prefix to use for automatic environment
@@ -1095,7 +1095,7 @@ def get_help_option(self, ctx: Context) -> Option | None:
10951095

10961096
# Cache the help option object in private _help_option attribute to
10971097
# avoid creating it multiple times. Not doing this will break the
1098-
# callback odering by iter_params_for_processing(), which relies on
1098+
# callback ordering by iter_params_for_processing(), which relies on
10991099
# object comparison.
11001100
if self._help_option is None:
11011101
# Avoid circular import.
@@ -2844,7 +2844,7 @@ def __init__(
28442844
if self.default is UNSET and not self.required:
28452845
self.default = False
28462846

2847-
# The alignement of default to the flag_value is resolved lazily in
2847+
# The alignment of default to the flag_value is resolved lazily in
28482848
# get_default() to prevent callable flag_values (like classes) from
28492849
# being instantiated. Refs:
28502850
# https://github.com/pallets/click/issues/3121

src/click/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def _match_short_opt(self, arg: str, state: _ParsingState) -> None:
421421

422422
# If we got any unknown options we recombine the string of the
423423
# remaining options and re-attach the prefix, then report that
424-
# to the state as new larg. This way there is basic combinatorics
424+
# to the state as new large. This way there is basic combinatorics
425425
# that can be achieved while still ignoring unknown arguments.
426426
if self.ignore_unknown_options and unknown_options:
427427
state.largs.append(f"{prefix}{''.join(unknown_options)}")

src/click/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ def convert_type(ty: t.Any | None, default: t.Any | None = None) -> ParamType:
11771177
#:
11781178
#: For path related uses the :class:`Path` type is a better choice but
11791179
#: there are situations where an unprocessed type is useful which is why
1180-
#: it is is provided.
1180+
#: it is provided.
11811181
#:
11821182
#: .. versionadded:: 4.0
11831183
UNPROCESSED = UnprocessedParamType()

tests/test_defaults.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def cli(arg):
8484

8585

8686
def test_multiple_flag_default(runner):
87-
"""Default default for flags when multiple=True should be empty tuple."""
87+
"""Default for flags when multiple=True should be empty tuple."""
8888

8989
@click.command
9090
# flag due to secondary token
@@ -274,7 +274,7 @@ def test_lookup_default_override_respected(runner):
274274
``None``.
275275
276276
Previous attempts in https://github.com/pallets/click/pr/3199 were entirely
277-
bypassing the user's overridded method.
277+
bypassing the user's overridden method.
278278
"""
279279

280280
class CustomContext(click.Context):

tests/test_options.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def cli(shout):
520520
"value",
521521
(
522522
# Extra spaces inside the value.
523-
"tr ue",
523+
"tr ue", # codespell:ignore ue
524524
"fa lse",
525525
# Numbers.
526526
"10",
@@ -999,13 +999,13 @@ def get_default(self, ctx, call=True):
999999
return "I am a default"
10001000

10011001
@click.command()
1002-
@click.argument("testarg", cls=CustomArgument, default="you wont see me")
1002+
@click.argument("testarg", cls=CustomArgument, default="you won't see me")
10031003
def cmd(testarg):
10041004
click.echo(testarg)
10051005

10061006
result = runner.invoke(cmd)
10071007
assert "I am a default" in result.output
1008-
assert "you wont see me" not in result.output
1008+
assert "you won't see me" not in result.output
10091009

10101010

10111011
def test_option_custom_class(runner):
@@ -1015,13 +1015,13 @@ def get_help_record(self, ctx):
10151015
return ("--help", "I am a help text")
10161016

10171017
@click.command()
1018-
@click.option("--testoption", cls=CustomOption, help="you wont see me")
1018+
@click.option("--testoption", cls=CustomOption, help="you won't see me")
10191019
def cmd(testoption):
10201020
click.echo(testoption)
10211021

10221022
result = runner.invoke(cmd, ["--help"])
10231023
assert "I am a help text" in result.output
1024-
assert "you wont see me" not in result.output
1024+
assert "you won't see me" not in result.output
10251025

10261026

10271027
@pytest.mark.parametrize(
@@ -1068,8 +1068,8 @@ def get_help_record(self, ctx):
10681068
"""a dumb override of a help text for testing"""
10691069
return ("--help", "I am a help text")
10701070

1071-
# Assign to a variable to re-use the decorator.
1072-
testoption = click.option("--testoption", cls=CustomOption, help="you wont see me")
1071+
# Assign to a variable to reuse the decorator.
1072+
testoption = click.option("--testoption", cls=CustomOption, help="you won't see me")
10731073

10741074
@click.command()
10751075
@testoption
@@ -1085,7 +1085,7 @@ def cmd2(testoption):
10851085
for cmd in (cmd1, cmd2):
10861086
result = runner.invoke(cmd, ["--help"])
10871087
assert "I am a help text" in result.output
1088-
assert "you wont see me" not in result.output
1088+
assert "you won't see me" not in result.output
10891089

10901090

10911091
@pytest.mark.parametrize("custom_class", (True, False))

tests/test_termui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def test_edit(runner):
396396
result = click.edit(filename=named_tempfile.name, editor="sed -i~ 's/$/Test/'")
397397
assert result is None
398398

399-
# We need ot reopen the file as it becomes unreadable after the edit.
399+
# We need to reopen the file as it becomes unreadable after the edit.
400400
with open(named_tempfile.name) as reopened_file:
401401
# POSIX says that when sed writes a pattern space to output then it
402402
# is immediately followed by a newline and so the expected result

0 commit comments

Comments
 (0)