Skip to content

Commit 9039ad5

Browse files
authored
Merge branch 'main' into dev/scriptconfig_integration
2 parents 1ee309c + e5ff8bc commit 9039ad5

24 files changed

+335
-45
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 4.31.0
2+
current_version = 4.32.1
33
commit = True
44
tag = True
55
tag_name = v{new_version}

.pre-commit-config.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ci:
1212
repos:
1313

1414
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: v4.5.0
15+
rev: v4.6.0
1616
hooks:
1717
- id: check-added-large-files
1818
- id: check-ast
@@ -24,12 +24,12 @@ repos:
2424
exclude: .bumpversion.cfg
2525

2626
- repo: https://github.com/psf/black
27-
rev: 24.3.0
27+
rev: 24.8.0
2828
hooks:
2929
- id: black
3030

3131
- repo: https://github.com/astral-sh/ruff-pre-commit
32-
rev: v0.3.7
32+
rev: v0.5.7
3333
hooks:
3434
- id: ruff
3535
args: ["--fix"]
@@ -40,14 +40,14 @@ repos:
4040
- id: yesqa
4141

4242
- repo: https://github.com/crate-ci/typos
43-
rev: v1.20.7
43+
rev: v1.23.6
4444
hooks:
4545
- id: typos
4646
args: []
4747
verbose: true
4848

4949
- repo: https://github.com/pre-commit/mirrors-mypy
50-
rev: v1.9.0
50+
rev: v1.11.1
5151
hooks:
5252
- id: mypy
5353
files: jsonargparse.*/.*.py
@@ -88,7 +88,7 @@ repos:
8888
if [ "$CHANGELOG" != "$EXPECTED" ] && [ $(echo $BUMPVERSION_NEW_VERSION | grep -cE "[0-9.]+(\.dev|rc)[0-9]+") = 0 ]; then
8989
if [ $(grep -c "^v$BUMPVERSION_NEW_VERSION " CHANGELOG.rst) = 1 ]; then
9090
echo "Updating the date for v$BUMPVERSION_NEW_VERSION in CHANGELOG.rst";
91-
sed -ir "s|^v$BUMPVERSION_NEW_VERSION .*|$EXPECTED|" CHANGELOG.rst;
91+
sed -i "s|^v$BUMPVERSION_NEW_VERSION .*|$EXPECTED|" CHANGELOG.rst;
9292
git add CHANGELOG.rst;
9393
else
9494
echo "Expected release in CHANGELOG.rst to be "$EXPECTED" or not have a definitive date.";
@@ -117,7 +117,7 @@ repos:
117117
trap cleanup EXIT;
118118
cp jsonargparse_tests/*.py "$TEST_DIR";
119119
cd "$TEST_DIR";
120-
sed -ir "/^from __future__ import annotations$/d" *.py;
120+
sed -i "/^from __future__ import annotations$/d" *.py;
121121
pytest $TEST_DIR;'
122122
stages: [pre-push]
123123
language: system
@@ -137,9 +137,9 @@ repos:
137137
cd "$TEST_DIR";
138138
pip install "pydantic<2";
139139
pytest test_dataclass_like.py;
140-
sed -ir "s|import pydantic|import pydantic.v1 as pydantic|" test_dataclass_like.py;
141-
sed -ir "s|^annotated = .*|annotated = False|" test_dataclass_like.py;
142-
sed -ir "s|test_pydantic_types|_test_pydantic_types|" test_dataclass_like.py;
140+
sed -i "s|import pydantic|import pydantic.v1 as pydantic|" test_dataclass_like.py;
141+
sed -i "s|^annotated = .*|annotated = False|" test_dataclass_like.py;
142+
sed -i "s|test_pydantic_types|_test_pydantic_types|" test_dataclass_like.py;
143143
pip install "pydantic>=2";
144144
pytest test_dataclass_like.py;'
145145
stages: [pre-push]

.sonarcloud.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
sonar.sources=jsonargparse
2-
sonar.projectVersion=4.31.0
2+
sonar.projectVersion=4.32.1
33
sonar.python.version=3.7, 3.8, 3.9, 3.10, 3.11, 3.12

CHANGELOG.rst

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,58 @@ The semantic versioning only considers the public API as described in
1212
paths are considered internals and can change in minor and patch releases.
1313

1414

15-
v4.32.0 (2024-07-??)
15+
v4.32.1 (2024-08-23)
16+
--------------------
17+
18+
Fixed
19+
^^^^^
20+
- ``dict`` types not correctly forwarding previous nested values when parsing
21+
(`#559 <https://github.com/omni-us/jsonargparse/pull/559>`__).
22+
- ``List`` type incorrectly using defaults from previous item (`#560
23+
<https://github.com/omni-us/jsonargparse/pull/560>`__).
24+
- ``--print_shtab`` not adding file completer for ``_ActionConfigLoad`` (`#562
25+
<https://github.com/omni-us/jsonargparse/pull/562>`__).
26+
- ``parser_mode`` not inherited by nested parsers (`#564
27+
<https://github.com/omni-us/jsonargparse/pull/564>`__).
28+
29+
30+
v4.32.0 (2024-07-19)
1631
--------------------
1732

1833
Added
1934
^^^^^
2035
- Support for ``MappingProxyType`` as a type and as default for mapping types
2136
(`#540 <https://github.com/omni-us/jsonargparse/pull/540>`__).
37+
- Support for ``OrderedDict`` as a type (`#545
38+
<https://github.com/omni-us/jsonargparse/pull/545>`__).
39+
- New function ``get_loader`` to get the current loader for a given parser mode
40+
(`#479 comment
41+
<https://github.com/omni-us/jsonargparse/issues/479#issuecomment-2022596544>`__,
42+
`#536 comment
43+
<https://github.com/omni-us/jsonargparse/issues/536#issuecomment-2186961644>`__).
44+
45+
Fixed
46+
^^^^^
47+
- ``dump`` failing when a link target requires serialization and
48+
``skip_link_targets=False`` (`#542
49+
<https://github.com/omni-us/jsonargparse/pull/542>`__).
50+
- ``default_config_files`` making parse fail for subcommands and nested subclass
51+
types (`lightning-forums#5963
52+
<https://lightning.ai/forums/t/problem-lightningcli-with-default-config-files/5963>`__).
53+
- Fixes related to transformers ``PreTrainedModel.from_pretrained``
54+
(`lightning#19863 comment
55+
<https://github.com/Lightning-AI/pytorch-lightning/discussions/19863#discussioncomment-9821765>`__):
56+
57+
- Import path of inherited classmethod not resolving correctly (`#548
58+
<https://github.com/omni-us/jsonargparse/pull/548>`__).
59+
- Resolved parameters leading to multiple values for keyword argument (`#551
60+
<https://github.com/omni-us/jsonargparse/pull/551>`__).
61+
- Function with return type a class in ``class_path`` in some cases fails
62+
with unexpected ``instantiate`` parameter error (`#551
63+
<https://github.com/omni-us/jsonargparse/pull/551>`__).
64+
- Ignore incorrectly resolved ``config_file_name`` parameter for
65+
transformers model ``from_pretrained``(`#551
66+
<https://github.com/omni-us/jsonargparse/pull/551>`__).
2267
2368
2469
v4.31.0 (2024-06-27)

DOCUMENTATION.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,9 @@ Some notes about this support are:
400400
:ref:`restricted-strings` and paths and URLs as explained in sections
401401
:ref:`parsing-paths` and :ref:`parsing-urls`.
402402

403-
- ``Dict``, ``Mapping``, ``MutableMapping``, ``MappingProxyType``, and
404-
``TypedDict`` are supported but only with ``str`` or ``int`` keys. For more
405-
details see :ref:`dict-items`.
403+
- ``Dict``, ``Mapping``, ``MutableMapping``, ``MappingProxyType``,
404+
``OrderedDict`` and ``TypedDict`` are supported but only with ``str`` or
405+
``int`` keys. For more details see :ref:`dict-items`.
406406

407407
- ``Tuple``, ``Set`` and ``MutableSet`` are supported even though they can't be
408408
represented in json distinguishable from a list. Each ``Tuple`` element

jsonargparse/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@
7070
__all__ += _deprecated.__all__
7171

7272

73-
__version__ = "4.31.0"
73+
__version__ = "4.32.1"

jsonargparse/_actions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,12 +580,12 @@ def add_prefix(key):
580580
@contextmanager
581581
def parent_parsers_context(key, parser):
582582
prev = parent_parsers.get()
583-
curr = prev + [(key, parser)]
584-
t = parent_parsers.set(curr)
583+
curr = [] if parser is None else prev + [(key, parser)]
584+
token = parent_parsers.set(curr)
585585
try:
586586
yield
587587
finally:
588-
parent_parsers.reset(t)
588+
parent_parsers.reset(token)
589589

590590

591591
class _ActionSubCommands(_SubParsersAction):

jsonargparse/_completions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from subprocess import PIPE, Popen
1313
from typing import List, Union
1414

15-
from ._actions import ActionConfigFile, _ActionHelpClassPath, remove_actions
15+
from ._actions import ActionConfigFile, _ActionConfigLoad, _ActionHelpClassPath, remove_actions
1616
from ._parameter_resolvers import get_signature_parameters
1717
from ._typehints import (
1818
ActionTypeHint,
@@ -142,7 +142,7 @@ def shtab_prepare_action(action, parser) -> None:
142142
return
143143

144144
complete = None
145-
if isinstance(action, ActionConfigFile):
145+
if isinstance(action, (ActionConfigFile, _ActionConfigLoad)):
146146
complete = shtab.FILE
147147
elif isinstance(action, ActionTypeHint):
148148
typehint = action._typehint

jsonargparse/_core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,9 @@ def _dump_cleanup_actions(self, cfg, actions, dump_kwargs, prefix=""):
754754
cfg.pop(action_dest, None)
755755
for key, subparser in action.choices.items():
756756
self._dump_cleanup_actions(cfg, subparser._actions, dump_kwargs, prefix=prefix + key + ".")
757-
elif isinstance(action, ActionTypeHint):
757+
elif isinstance(action, ActionLink):
758+
action = action.target[1]
759+
if isinstance(action, ActionTypeHint):
758760
value = cfg.get(action_dest)
759761
if value is not None:
760762
with parser_context(parent_parser=self):

jsonargparse/_loaders_dumpers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from ._type_checking import ArgumentParser
1212

1313
__all__ = [
14+
"get_loader",
1415
"set_loader",
1516
"set_dumper",
1617
]
@@ -202,6 +203,11 @@ def set_loader(mode: str, loader_fn: Callable[[str], Any], exceptions: Tuple[Typ
202203
loader_exceptions[mode] = exceptions
203204

204205

206+
def get_loader(mode: str):
207+
"""Returns the current loader function for a given mode."""
208+
return loaders[mode]
209+
210+
205211
def set_dumper(format_name: str, dumper_fn: Callable[[Any], str]):
206212
"""Sets the dumping function for a given format name.
207213

0 commit comments

Comments
 (0)