Skip to content

Commit 60a8525

Browse files
authored
bump version, merge pull request #81 from iterative/fix-spaces
2 parents cf19980 + b0b6d53 commit 60a8525

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ default_language_version:
22
python: python3
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.1.0
5+
rev: v4.3.0
66
hooks:
77
- id: check-added-large-files
88
- id: check-case-conflict
@@ -39,7 +39,7 @@ repos:
3939
- flake8-string-format
4040
- flake8-type-annotations
4141
- repo: https://github.com/pre-commit/mirrors-mypy
42-
rev: v0.930
42+
rev: v0.961
4343
hooks:
4444
- id: mypy
4545
- repo: https://github.com/google/yapf

shtab/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ def recurse(parser, prefix):
225225
this_positional_choices.append(str(choice))
226226

227227
if this_positional_choices:
228-
choices.append(u"{}_pos_{}_choices='{}'".format(
229-
prefix, i, " ".join(this_positional_choices)))
228+
choices.append(u"{}_pos_{}_choices=('{}')".format(
229+
prefix, i, "' '".join(this_positional_choices)))
230230

231231
# skip default `nargs` values
232232
if positional.nargs not in (None, "1", "?"):
@@ -266,8 +266,8 @@ def recurse(parser, prefix):
266266
this_optional_choices.append(str(choice))
267267

268268
if this_optional_choices:
269-
choices.append(u"{}_{}_choices='{}'".format(
270-
prefix, wordify(option_string), " ".join(this_optional_choices)))
269+
choices.append(u"{}_{}_choices=('{}')".format(
270+
prefix, wordify(option_string), "' '".join(this_optional_choices)))
271271

272272
# Check for nargs.
273273
if optional.nargs is not None and optional.nargs != 1:
@@ -421,8 +421,9 @@ def complete_bash(parser, root_prefix=None, preamble="", choice_functions=None):
421421
COMPREPLY=( $(compgen -W "${current_option_strings[*]}" -- "${completing_word}") )
422422
else
423423
# use choices & compgen
424-
COMPREPLY=( $(compgen -W "${current_action_choices}" -- "${completing_word}"; \\
425-
[ -n "${current_action_compgen}" ] \\
424+
local IFS=$'\\n'
425+
COMPREPLY=( $(compgen -W "${current_action_choices}" -- "${completing_word}") \\
426+
$([ -n "${current_action_compgen}" ] \\
426427
&& "${current_action_compgen}" "${completing_word}") )
427428
fi
428429

tests/test_shtab.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ def test_subparser_aliases(shell, caplog):
197197
if shell == "bash":
198198
shell = Bash(completion)
199199
shell.compgen('-W "${_shtab_test_subparsers[*]}"', "s", "sub")
200-
shell.compgen('-W "$_shtab_test_pos_0_choices"', "s", "sub")
200+
shell.compgen('-W "${_shtab_test_pos_0_choices[*]}"', "s", "sub")
201201
shell.compgen('-W "${_shtab_test_subparsers[*]}"', "x", "xsub")
202-
shell.compgen('-W "$_shtab_test_pos_0_choices"', "x", "xsub")
202+
shell.compgen('-W "${_shtab_test_pos_0_choices[*]}"', "x", "xsub")
203203
shell.compgen('-W "${_shtab_test_subparsers[*]}"', "y", "ysub")
204-
shell.compgen('-W "$_shtab_test_pos_0_choices"', "y", "ysub")
204+
shell.compgen('-W "${_shtab_test_pos_0_choices[*]}"', "y", "ysub")
205205
shell.test('"$($_shtab_test_sub_pos_0_COMPGEN o)" = "one"')
206206
shell.test('-z "$_shtab_test_COMPGEN"')
207207

@@ -245,9 +245,9 @@ def test_add_argument_to_positional(shell, caplog, capsys):
245245
if shell == "bash":
246246
shell = Bash(completion)
247247
shell.compgen('-W "${_shtab_test_subparsers[*]}"', "c", "completion")
248-
shell.compgen('-W "$_shtab_test_pos_0_choices"', "c", "completion")
249-
shell.compgen('-W "$_shtab_test_completion_pos_0_choices"', "ba", "bash")
250-
shell.compgen('-W "$_shtab_test_completion_pos_0_choices"', "z", "zsh")
248+
shell.compgen('-W "${_shtab_test_pos_0_choices[*]}"', "c", "completion")
249+
shell.compgen('-W "${_shtab_test_completion_pos_0_choices[*]}"', "ba", "bash")
250+
shell.compgen('-W "${_shtab_test_completion_pos_0_choices[*]}"', "z", "zsh")
251251

252252
assert not caplog.record_tuples
253253

0 commit comments

Comments
 (0)