|
37 | 37 | if importlib.metadata.version("click") < "8.2": |
38 | 38 | from click.parser import split_opt |
39 | 39 | else: |
40 | | - from click.parser import ( # type: ignore[attr-defined, no-redef, unused-ignore] |
41 | | - _split_opt as split_opt, |
42 | | - ) |
| 40 | + from click.parser import _split_opt as split_opt # ty: ignore[unresolved-import] |
43 | 41 |
|
44 | 42 |
|
45 | | -class EnumChoice(Choice): # type: ignore[type-arg, unused-ignore] |
| 43 | +class EnumChoice(Choice): |
46 | 44 | """An enum-based choice type. |
47 | 45 |
|
48 | 46 | The implementation is copied from https://github.com/pallets/click/pull/2210 and |
@@ -75,7 +73,7 @@ def convert(self, value: Any, param: Parameter | None, ctx: Context | None) -> A |
75 | 73 | class _OptionHighlighter(RegexHighlighter): |
76 | 74 | """A highlighter for help texts.""" |
77 | 75 |
|
78 | | - highlights: ClassVar = [ # type: ignore[misc] |
| 76 | + highlights: ClassVar = [ |
79 | 77 | r"(?P<switch>\-\w)\b", |
80 | 78 | r"(?P<option>\-\-[\w\-]+)", |
81 | 79 | r"\-\-[\w\-]+(?P<metavar>[ |=][\w\.:]+)", |
@@ -114,7 +112,7 @@ def format_help( |
114 | 112 | else: |
115 | 113 | formatted_name = Text(command_name, style="command") |
116 | 114 |
|
117 | | - commands_table.add_row(formatted_name, highlighter(command.help)) |
| 115 | + commands_table.add_row(formatted_name, highlighter(command.help or "")) |
118 | 116 |
|
119 | 117 | console.print( |
120 | 118 | Panel( |
@@ -177,12 +175,13 @@ def parse_args(self, ctx: Context, args: list[str]) -> list[str]: |
177 | 175 | _value, args = param.handle_parse_result(ctx, opts, args) |
178 | 176 |
|
179 | 177 | if args and not ctx.allow_extra_args and not ctx.resilient_parsing: |
| 178 | + args_list = list(args) if not isinstance(args, list) else args |
180 | 179 | ctx.fail( |
181 | 180 | ngettext( |
182 | 181 | "Got unexpected extra argument ({args})", |
183 | 182 | "Got unexpected extra arguments ({args})", |
184 | 183 | len(args), |
185 | | - ).format(args=" ".join(map(str, args))) |
| 184 | + ).format(args=" ".join(str(arg) for arg in args_list)) |
186 | 185 | ) |
187 | 186 |
|
188 | 187 | ctx.args = args |
@@ -328,7 +327,7 @@ def _format_help_text( # noqa: C901, PLR0912, PLR0915 |
328 | 327 | elif param.is_bool_flag and param.secondary_opts: # type: ignore[attr-defined] |
329 | 328 | # For boolean flags that have distinct True/False opts, |
330 | 329 | # use the opt without prefix instead of the value. |
331 | | - default_string = split_opt( # type: ignore[operator, unused-ignore] |
| 330 | + default_string = split_opt( |
332 | 331 | (param.opts if param.default else param.secondary_opts)[0] |
333 | 332 | )[1] |
334 | 333 | elif ( |
|
0 commit comments