Skip to content

Commit

Permalink
bump version, merge pull request #81 from iterative/fix-spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl authored Jun 17, 2022
2 parents cf19980 + b0b6d53 commit 60a8525
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down Expand Up @@ -39,7 +39,7 @@ repos:
- flake8-string-format
- flake8-type-annotations
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.930
rev: v0.961
hooks:
- id: mypy
- repo: https://github.com/google/yapf
Expand Down
13 changes: 7 additions & 6 deletions shtab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ def recurse(parser, prefix):
this_positional_choices.append(str(choice))

if this_positional_choices:
choices.append(u"{}_pos_{}_choices='{}'".format(
prefix, i, " ".join(this_positional_choices)))
choices.append(u"{}_pos_{}_choices=('{}')".format(
prefix, i, "' '".join(this_positional_choices)))

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

if this_optional_choices:
choices.append(u"{}_{}_choices='{}'".format(
prefix, wordify(option_string), " ".join(this_optional_choices)))
choices.append(u"{}_{}_choices=('{}')".format(
prefix, wordify(option_string), "' '".join(this_optional_choices)))

# Check for nargs.
if optional.nargs is not None and optional.nargs != 1:
Expand Down Expand Up @@ -421,8 +421,9 @@ def complete_bash(parser, root_prefix=None, preamble="", choice_functions=None):
COMPREPLY=( $(compgen -W "${current_option_strings[*]}" -- "${completing_word}") )
else
# use choices & compgen
COMPREPLY=( $(compgen -W "${current_action_choices}" -- "${completing_word}"; \\
[ -n "${current_action_compgen}" ] \\
local IFS=$'\\n'
COMPREPLY=( $(compgen -W "${current_action_choices}" -- "${completing_word}") \\
$([ -n "${current_action_compgen}" ] \\
&& "${current_action_compgen}" "${completing_word}") )
fi
Expand Down
12 changes: 6 additions & 6 deletions tests/test_shtab.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ def test_subparser_aliases(shell, caplog):
if shell == "bash":
shell = Bash(completion)
shell.compgen('-W "${_shtab_test_subparsers[*]}"', "s", "sub")
shell.compgen('-W "$_shtab_test_pos_0_choices"', "s", "sub")
shell.compgen('-W "${_shtab_test_pos_0_choices[*]}"', "s", "sub")
shell.compgen('-W "${_shtab_test_subparsers[*]}"', "x", "xsub")
shell.compgen('-W "$_shtab_test_pos_0_choices"', "x", "xsub")
shell.compgen('-W "${_shtab_test_pos_0_choices[*]}"', "x", "xsub")
shell.compgen('-W "${_shtab_test_subparsers[*]}"', "y", "ysub")
shell.compgen('-W "$_shtab_test_pos_0_choices"', "y", "ysub")
shell.compgen('-W "${_shtab_test_pos_0_choices[*]}"', "y", "ysub")
shell.test('"$($_shtab_test_sub_pos_0_COMPGEN o)" = "one"')
shell.test('-z "$_shtab_test_COMPGEN"')

Expand Down Expand Up @@ -245,9 +245,9 @@ def test_add_argument_to_positional(shell, caplog, capsys):
if shell == "bash":
shell = Bash(completion)
shell.compgen('-W "${_shtab_test_subparsers[*]}"', "c", "completion")
shell.compgen('-W "$_shtab_test_pos_0_choices"', "c", "completion")
shell.compgen('-W "$_shtab_test_completion_pos_0_choices"', "ba", "bash")
shell.compgen('-W "$_shtab_test_completion_pos_0_choices"', "z", "zsh")
shell.compgen('-W "${_shtab_test_pos_0_choices[*]}"', "c", "completion")
shell.compgen('-W "${_shtab_test_completion_pos_0_choices[*]}"', "ba", "bash")
shell.compgen('-W "${_shtab_test_completion_pos_0_choices[*]}"', "z", "zsh")

assert not caplog.record_tuples

Expand Down

0 comments on commit 60a8525

Please sign in to comment.