Skip to content

Commit

Permalink
Fix --print_shtab not adding file completer for _ActionConfigLoad (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
mauvilsa authored Aug 16, 2024
1 parent f7aa49f commit 54ff57e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Fixed
(`#559 <https://github.com/omni-us/jsonargparse/pull/559>`__).
- ``List`` type incorrectly using defaults from previous item (`#560
<https://github.com/omni-us/jsonargparse/pull/560>`__).
- ``--print_shtab`` not adding file completer for ``_ActionConfigLoad`` (`#562
<https://github.com/omni-us/jsonargparse/pull/562>`__).


v4.32.0 (2024-07-19)
Expand Down
4 changes: 2 additions & 2 deletions jsonargparse/_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from subprocess import PIPE, Popen
from typing import List, Union

from ._actions import ActionConfigFile, _ActionHelpClassPath, remove_actions
from ._actions import ActionConfigFile, _ActionConfigLoad, _ActionHelpClassPath, remove_actions
from ._parameter_resolvers import get_signature_parameters
from ._typehints import (
ActionTypeHint,
Expand Down Expand Up @@ -142,7 +142,7 @@ def shtab_prepare_action(action, parser) -> None:
return

complete = None
if isinstance(action, ActionConfigFile):
if isinstance(action, (ActionConfigFile, _ActionConfigLoad)):
complete = shtab.FILE
elif isinstance(action, ActionTypeHint):
typehint = action._typehint
Expand Down
6 changes: 6 additions & 0 deletions jsonargparse_tests/test_shtab.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ def __init__(self, p1: int):
pass


def test_bash_class_config(parser):
parser.add_class_arguments(Base, "class")
shtab_script = get_shtab_script(parser, "bash")
assert "_class_COMPGEN=_shtab_compgen_files" in shtab_script


class SubA(Base):
def __init__(self, p1: int, p2: AXEnum):
pass
Expand Down

0 comments on commit 54ff57e

Please sign in to comment.