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
6 changes: 5 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ The semantic versioning only considers the public API as described in
:ref:`api-ref`. Components not mentioned in :ref:`api-ref` or different import
paths are considered internals and can change in minor and patch releases.


v4.42.1 (unreleased)
--------------------

Fixed
^^^^^
- Prevent extra environment variables in helptext when default_env=True, for
version actions and subcommands(`#787
version actions and subcommands (`#787
<https://github.com/omni-us/jsonargparse/pull/787>`__).
- ``Union`` with path type and non-path value incorrectly dumped as string
(`#789 <https://github.com/omni-us/jsonargparse/pull/789>`__).


v4.42.0 (2025-10-14)
--------------------
Expand Down
2 changes: 2 additions & 0 deletions jsonargparse/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ def _is_path_type(value, type_class):


def _serialize_path(path: Path):
if not isinstance(path, Path):
raise ValueError("Expected a Path instance.")
if path_dump_preserve_relative.get() and path.relative != path.absolute:
return {
"relative": path._relative,
Expand Down
6 changes: 6 additions & 0 deletions jsonargparse_tests/test_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1590,3 +1590,9 @@ def mocked_get_import_path(cls):
subclass_paths = get_all_subclass_paths(ImportClass)
assert "Failed to import ImportClass" in str(w[0].message)
assert subclass_paths == []


def test_non_path_dump(parser):
parser.add_argument("--data", type=Union[Path_fr, Dict[str, List[str]]])
cfg = parser.parse_args(['--data={"key": ["value"]}'])
assert json_or_yaml_load(parser.dump(cfg)) == {"data": {"key": ["value"]}}