Skip to content

Fix help types, dump skip_default, kwargs pop and shtab redraw - #954

Merged
mauvilsa merged 5 commits into
mainfrom
some-fixes
Aug 13, 2026
Merged

Fix help types, dump skip_default, kwargs pop and shtab redraw#954
mauvilsa merged 5 commits into
mainfrom
some-fixes

Conversation

@mauvilsa

Copy link
Copy Markdown
Owner

What does this PR do?

Four unrelated bug fixes, each in its own commit.

Mangled types in the help

type_to_str produced the type string by running a regex over str(typehint) to
strip module names. That regex also matched anything else with a dot, so floats,
dotted literal values and ... in a Callable came out mangled, e.g.
Literal[1.5] shown as Literal[5].

The string is now built by recreating the type hint with its subtypes already
converted to strings, so only the outermost level goes through the module name
stripping and literal values and Annotated metadata are never touched. As part
of this, None in a PEP 604 union is now shown as null, e.g. date | null
instead of date | None, matching what parsing actually accepts.

--print_config=skip_default with an optional subclass

dump with skip_default=True failed with
AttributeError: 'NoneType' object has no attribute 'get' when a subclass spec
was given for an argument whose default is None, e.g. an
Optional[SomeClass] parameter. Now the class_path is kept in the dump and
only the init_args that equal the defaults are removed.

Parameters popped from **kwargs and forwarded explicitly

A parameter taken with kwargs.pop("x", None) or kwargs.get("x") disappeared
from the resolved parameters when the value was afterwards forwarded as an
explicit keyword, e.g. super().__init__(x=x, **kwargs). The explicit keyword
was treated as removing the parameter. A pop or get from **kwargs now marks
the parameter as accepted regardless of how it is forwarded.

shtab bash completion leaving the cursor on an empty line

When there are zero completions only the type guidance message is printed, so
readline does not redraw the prompt. The previous kill -WINCH workaround stopped
working as of bash 5.3, since readline redraws only if the terminal size actually
changed. The completion now asks the terminal for a device status report and binds
the reply to redraw-current-line, so readline redraws itself once the completion
function returns.

Before submitting

  • Did you read the contributing guideline?
  • If you used a coding agent, did you fully understand and validate all generated code and ensure it follows the contributing guidelines?
  • [n/a] Did you update the documentation? (readme and public docstrings)
  • Did you write unit tests such that there is 100% coverage on related code? (required for bug fixes and new features)
  • Did you verify that new and existing tests pass locally?
  • If this is a bug fix, did you verify that the tests fail without the code fix?
  • Did you make sure that all changes preserve backward compatibility?
  • Did you update the CHANGELOG including a pull request link? (not for typos, docs, test updates, or minor internal changes/refactors)

@mauvilsa mauvilsa changed the title Several fixes Fix help types, dump skip_default, kwargs pop and shtab redraw Aug 13, 2026
Comment thread jsonargparse_tests/test_typehints.py Dismissed
@mauvilsa
mauvilsa deployed to sonarcloud August 13, 2026 06:01 — with GitHub Actions Active
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a54f8e8) to head (30e8dd9).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #954   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         8390      8444   +54     
=========================================
+ Hits          8390      8444   +54     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@sonarqubecloud

Copy link
Copy Markdown

@mauvilsa
mauvilsa merged commit 553c8b0 into main Aug 13, 2026
32 checks passed
@mauvilsa
mauvilsa deleted the some-fixes branch August 13, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants