add codespell pre-commit hook (#3373)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by GitHub · parents d777956, e3c0898 · Browse files · 11 files·+26 added−21 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
11 files+26 added−21 removed
- tests:+12 added−12 removed
- other:+14 added−9 removed
Provenance
- Commit
8bd8b4a- Tree
20a1426- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
d777956- Parent 2
e3c0898
11 files changed+26 added−21 removed
modified:examples/aliases/aliases.py+1 added-1 removed
38 unmodified lines39 file and with a bit of magic.40 """41 42 def get_command(self, ctx, cmd_name):43- # Step one: bulitin commands as normal43+ # Step one: built-in commands as normal44 rv = click.Group.get_command(self, ctx, cmd_name)45 if rv is not None:46 return rv47 96 unmodified linesmodified:examples/repo/repo.py+1 added-1 removed
46 unmodified lines47 48 This tool is supposed to look like a distributed version control49 system to show how something like this can be structured.50 """51- # Create a repo object and remember it as as the context object. From51+ # Create a repo object and remember it as the context object. From52 # this point onwards other commands can refer to it by using the53 # @pass_repo decorator.54 ctx.obj = Repo(os.path.abspath(repo_home))55 ctx.obj.verbose = verbose111 unmodified linesmodified:src/click/core.py+3 added-3 removed
194 unmodified lines195 :param parent: the parent context.196 :param info_name: the info name for this invocation. Generally this197 is the most descriptive name for the script or198 command. For the toplevel script it is usually199- the name of the script, for commands below it it's199+ the name of the script, for commands below that it's200 the name of the script.201 :param obj: an arbitrary object of user data.202 :param auto_envvar_prefix: the prefix to use for automatic environment203 variables. If this is `None` then reading890 unmodified lines1094 return None1095 1096 # Cache the help option object in private _help_option attribute to1097 # avoid creating it multiple times. Not doing this will break the1098- # callback odering by iter_params_for_processing(), which relies on1098+ # callback ordering by iter_params_for_processing(), which relies on1099 # object comparison.1100 if self._help_option is None:1101 # Avoid circular import.1102 from .decorators import help_option1740 unmodified lines2843 if self.is_bool_flag:2844 if self.default is UNSET and not self.required:2845 self.default = False2846 2847- # The alignement of default to the flag_value is resolved lazily in2847+ # The alignment of default to the flag_value is resolved lazily in2848 # get_default() to prevent callable flag_values (like classes) from2849 # being instantiated. Refs:2850 # https://github.com/pallets/click/issues/31212851 # https://github.com/pallets/click/issues/3024#issuecomment-3146199461625 unmodified linesmodified:src/click/parser.py+1 added-1 removed
419 unmodified lines420 break421 422 # If we got any unknown options we recombine the string of the423 # remaining options and re-attach the prefix, then report that424- # to the state as new larg. This way there is basic combinatorics424+ # to the state as new large. This way there is basic combinatorics425 # that can be achieved while still ignoring unknown arguments.426 if self.ignore_unknown_options and unknown_options:427 state.largs.append(f"{prefix}{''.join(unknown_options)}")428 104 unmodified linesmodified:src/click/types.py+1 added-1 removed
1175 unmodified lines1176 #: appear in bytes and unicode.1177 #:1178 #: For path related uses the :class:`Path` type is a better choice but1179 #: there are situations where an unprocessed type is useful which is why1180-#: it is is provided.1180+#: it is provided.1181 #:1182 #: .. versionadded:: 4.01183 UNPROCESSED = UnprocessedParamType()1184 25 unmodified linesmodified:tests/test_defaults.py+2 added-2 removed
82 unmodified lines83 assert result.output.splitlines() == ["<1|2>", "<3|4>"]84 85 86 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."""88 89 @click.command90 # flag due to secondary token91 @click.option("-y/-n", multiple=True)181 unmodified lines273 subclass that falls back to prefix-based lookup when the parent returns274 ``None``.275 276 Previous attempts in https://github.com/pallets/click/pr/3199 were entirely277- bypassing the user's overridded method.277+ bypassing the user's overridden method.278 """279 280 class CustomContext(click.Context):281 def lookup_default(self, name, call=True):95 unmodified linesmodified:tests/test_options.py+8 added-8 removed
518 unmodified lines519 @pytest.mark.parametrize(520 "value",521 (522 # Extra spaces inside the value.523- "tr ue",523+ "tr ue", # codespell:ignore ue524 "fa lse",525 # Numbers.526 "10",527 "01",470 unmodified lines998 """a dumb override of a default value for testing"""999 return "I am a default"1000 1001 @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")1003 def cmd(testarg):1004 click.echo(testarg)1005 1006 result = runner.invoke(cmd)1007 assert "I am a default" in result.output1008- assert "you wont see me" not in result.output1008+ assert "you won't see me" not in result.output1009 1010 1011 def test_option_custom_class(runner):1012 class CustomOption(click.Option):1 unmodified line1014 """a dumb override of a help text for testing"""1015 return ("--help", "I am a help text")1016 1017 @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")1019 def cmd(testoption):1020 click.echo(testoption)1021 1022 result = runner.invoke(cmd, ["--help"])1023 assert "I am a help text" in result.output1024- assert "you wont see me" not in result.output1024+ assert "you won't see me" not in result.output1025 1026 1027 @pytest.mark.parametrize(1028 ("param_decl", "option_kwargs", "pass_argv"),38 unmodified lines1067 def get_help_record(self, ctx):1068 """a dumb override of a help text for testing"""1069 return ("--help", "I am a help text")1070 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")1073 1074 @click.command()1075 @testoption1076 def cmd1(testoption):7 unmodified lines1084 # Both of the commands should have the --help option now.1085 for cmd in (cmd1, cmd2):1086 result = runner.invoke(cmd, ["--help"])1087 assert "I am a help text" in result.output1088- assert "you wont see me" not in result.output1088+ assert "you won't see me" not in result.output1089 1090 1091 @pytest.mark.parametrize("custom_class", (True, False))1092 @pytest.mark.parametrize(1483 unmodified linesmodified:tests/test_termui.py+1 added-1 removed
394 unmodified lines395 396 result = click.edit(filename=named_tempfile.name, editor="sed -i~ 's/$/Test/'")397 assert result is None398 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.400 with open(named_tempfile.name) as reopened_file:401 # POSIX says that when sed writes a pattern space to output then it402 # is immediately followed by a newline and so the expected result403 # should contain the newline. However, some sed implementations587 unmodified linesmodified:tests/test_types.py+1 added-1 removed
226 unmodified lines227 path = tmp_path / "\udcff"228 229 # - common case: �': No such file or directory230 # - special case: Illegal byte sequence231- # The spacial case is seen with rootless Podman. The root cause is most231+ # The special case is seen with rootless Podman. The root cause is most232 # likely that the path is handled by a user-space program (FUSE).233 match = r"(�': No such file or directory|Illegal byte sequence)"234 with pytest.raises(click.BadParameter, match=match):235 type.convert(path, None, None)22 unmodified linesmodified:.pre-commit-config.yaml+6 added-1 removed
1 repos:2 - repo: https://github.com/astral-sh/ruff-pre-commit3 rev: c60c980e561ed3e73101667fe8365c609d19a438 # frozen: v0.15.94 hooks:5- - id: ruff5+ - id: ruff-check6 - id: ruff-format7 - repo: https://github.com/astral-sh/uv-pre-commit8 rev: 0397b68f6f88c024f1d2b355a9818779f6336d16 # frozen: 0.11.39 hooks:10 - id: uv-lock11+ - repo: https://github.com/codespell-project/codespell12+ rev: 2ccb47ff45ad361a21071a7eedda4c37e6ae8c5a # frozen: v2.4.213+ hooks:14+ - id: codespell15+ args: ['--write-changes', '--ignore-words-list=inout,te']16 - repo: https://github.com/pre-commit/pre-commit-hooks17 rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.018 hooks:19 - id: check-merge-conflict5 unmodified linesmodified:CHANGES.rst+1 added-1 removed
940 unmodified lines941 - ``_AtomicFile`` now uses the ``realpath`` of the original filename942 so that changing the working directory does not affect it. :pr:`920`943 - Fix incorrect completions when defaults are present :issue:`925`,944 :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.946 :issue:`926`, :pr:`994`947 - "x" and "a" file modes now use stdout when file is ``"-"``.948 :pr:`929`949 - Fix missing comma in ``__all__`` list. :pr:`935`420 unmodified lines