Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --print_shtab not adding file completer for _ActionConfigLoad #562

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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