Skip to content
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
3 changes: 0 additions & 3 deletions jsonargparse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from ._link_arguments import * # noqa: F403
from ._loaders_dumpers import * # noqa: F403
from ._namespace import * # noqa: F403
from ._optionals import * # noqa: F403
from ._paths import Path # noqa: F401
from ._signatures import * # noqa: F403
from ._subcommands import * # noqa: F403
Expand Down Expand Up @@ -53,7 +52,6 @@
_link_arguments,
_loaders_dumpers,
_namespace,
_optionals,
_signatures,
_subcommands,
_util,
Expand All @@ -70,7 +68,6 @@
__all__ += _actions.__all__
__all__ += _namespace.__all__
__all__ += _formatters.__all__
__all__ += _optionals.__all__
__all__ += _common.__all__
__all__ += _loaders_dumpers.__all__
__all__ += _util.__all__
Expand Down
2 changes: 1 addition & 1 deletion jsonargparse/_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

__all__ = [
"ActionFail",
"ActionParser",
"ActionYesNo",
"ActionParser",
]


Expand Down
5 changes: 1 addition & 4 deletions jsonargparse/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
from ._optionals import get_doc_short_description
from ._util import capture_parser, default_config_option_help

__all__ = [
"auto_cli",
"auto_parser",
]
__all__ = ["auto_cli", "auto_parser"]


ComponentType = Union[Callable, type]
Expand Down
12 changes: 5 additions & 7 deletions jsonargparse/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ def __init__(
*args,
env_prefix: Union[bool, str] = True,
formatter_class: type[argparse.HelpFormatter] = DefaultHelpFormatter,
exit_on_error: bool = True,
logger: Union[logging.Logger, bool, str, dict] = False,
version: Optional[str] = None,
print_config: Optional[str] = "--print_config",
Expand Down Expand Up @@ -274,7 +273,6 @@ def __init__(
self._group_class = get_argument_group_class(self)
if self.groups is None:
self.groups = {}
self.exit_on_error = exit_on_error
self._extra_required_keys: set[str] = set()
self.save_path_content: set[str] = set()
self.default_config_files = default_config_files
Expand Down Expand Up @@ -431,7 +429,7 @@ def parse_args( # type: ignore[override]
A config object with all parsed values.

Raises:
ArgumentError: If the parsing fails and ``exit_on_error=True``.
ArgumentError: If the parsing fails and ``exit_on_error=False``.
"""
skip_validation, namespace_as_config = get_private_kwargs(
kwargs, _skip_validation=False, _namespace_as_config=False
Expand Down Expand Up @@ -498,7 +496,7 @@ def parse_object(
A config object with all parsed values.

Raises:
ArgumentError: If the parsing fails and ``exit_on_error=True``.
ArgumentError: If the parsing fails and ``exit_on_error=False``.
"""
skip_validation, skip_required = get_private_kwargs(kwargs, _skip_validation=False, _skip_required=False)

Expand Down Expand Up @@ -581,7 +579,7 @@ def parse_env(
A config object with all parsed values.

Raises:
ArgumentError: If the parsing fails and ``exit_on_error=True``.
ArgumentError: If the parsing fails and ``exit_on_error=False``.
"""
skip_validation, skip_subcommands = get_private_kwargs(kwargs, _skip_validation=False, _skip_subcommands=False)

Expand Down Expand Up @@ -625,7 +623,7 @@ def parse_path(
A config object with all parsed values.

Raises:
ArgumentError: If the parsing fails and ``exit_on_error=True``.
ArgumentError: If the parsing fails and ``exit_on_error=False``.
"""
fpath = Path(cfg_path, mode=_get_config_read_mode())
with change_to_path_dir(fpath):
Expand Down Expand Up @@ -664,7 +662,7 @@ def parse_string(
A config object with all parsed values.

Raises:
ArgumentError: If the parsing fails and ``exit_on_error=True``.
ArgumentError: If the parsing fails and ``exit_on_error=False``.
"""
skip_validation, fail_no_subcommand = get_private_kwargs(
kwargs, _skip_validation=False, _fail_no_subcommand=True
Expand Down
5 changes: 0 additions & 5 deletions jsonargparse/_optionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
from importlib.util import find_spec
from typing import Any, Optional, Union

__all__ = [
"_get_config_read_mode",
]


pyyaml_available = bool(find_spec("yaml"))
toml_load_available = bool(find_spec("toml") or find_spec("tomllib"))
toml_dump_available = bool(find_spec("toml"))
Expand Down
4 changes: 2 additions & 2 deletions jsonargparse/_postponed_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def _collect_string_fwd_ref_names(typehint: Any, result: set[str]) -> None:


def _update_missing_from_module_vars(global_vars: dict, missing: set[str], mod_vars: dict[str, Any]) -> None:
for name in list(missing):
for name in missing.copy():
if name in mod_vars:
global_vars[name] = mod_vars[name]
missing.discard(name)
Expand Down Expand Up @@ -284,7 +284,7 @@ def _enrich_globals_for_string_forward_refs(global_vars: dict[str, Any]) -> None

# Find candidate modules: those that define the same trigger values (by identity).
# This lets us trace generic aliases back to their origin module.
for module_name, mod in list(sys.modules.items()):
for mod in sys.modules.values():
if mod is None or not missing:
continue
try:
Expand Down
9 changes: 3 additions & 6 deletions jsonargparse/_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,13 @@ def _add_signature_parameter(
if kind == kinds.POSITIONAL_ONLY:
is_required = True # Always required
is_non_positional = False # Can be positional
elif kind == kinds.POSITIONAL_OR_KEYWORD:
is_required = default == inspect_empty # Required if no default
is_non_positional = False # Can be positional
elif kind == kinds.KEYWORD_ONLY:
is_required = default == inspect_empty # Required if no default
is_non_positional = True # Must use --flag style
elif kind is None:
# programmatically created parameters without kind
elif kind in {kinds.POSITIONAL_OR_KEYWORD, None}:
# POSITIONAL_OR_KEYWORD or programmatically created parameters without kind
is_required = default == inspect_empty # Required if no default
is_non_positional = False # Can be positional (preserve old behavior)
is_non_positional = False # Can be positional
else:
raise RuntimeError(f"The code should never reach here: kind={kind}") # pragma: no cover
src = get_parameter_origins(param.component, param.parent)
Expand Down
Loading