Skip to content

TypedDict help+completions, Any/Unvalidated dumping, scoped postponed annotations, abstract dataclass-like types and pydantic/attrs aliases - #956

Merged
mauvilsa merged 6 commits into
mainfrom
improvements
Aug 17, 2026
Merged

TypedDict help+completions, Any/Unvalidated dumping, scoped postponed annotations, abstract dataclass-like types and pydantic/attrs aliases#956
mauvilsa merged 6 commits into
mainfrom
improvements

Conversation

@mauvilsa

Copy link
Copy Markdown
Owner

What does this PR do?

Five independent improvements, one per commit:

  • TypedDict help and completions — arguments typed as a TypedDict now have a --*.help option listing the accepted keys, their types and their descriptions; add_class_arguments accepts a TypedDict, adding one argument per key; docstring descriptions of keys are shown for **kwargs: Unpack[SomeTypedDict] parameters; and shtab completion scripts include the keys and the values they accept, no longer showing NotRequired[...] as the expected type.

  • Dumping of Any and Unvalidated valuesdump, and thus --print_config, no longer fails when the value is of a type the config format can't represent, e.g. a class instance, or a set in json. A type is now derived from the value and used to serialize it, class instances become an import path or a not-serializable message, and a warning is raised when the dumped value does not round-trip.

  • Postponed annotations of methods — names defined in the body of a class are now resolved for its methods' annotations, by using the class namespace as locals.

  • Abstract dataclass-like types — these now have subclass support enabled by default, since previously they were unusable: the class_path of an implementation was rejected and giving the fields directly failed on instantiate. Additionally, the class_path of an abstract class is now rejected at parse time with Expected an instantiatable class, but ... is abstract, instead of failing later on instantiate. This also applies when the class_path is implicit or the class is given by name.

  • pydantic and attrs field aliases — pydantic's alias and validation_alias and attrs' alias are now accepted as option and config keys, so a parser accepts the same names as the class itself. This fixes values being silently discarded for pydantic models without populate_by_name and attrs fields with an explicit alias or a private attribute failing to instantiate.

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?
  • 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 added bug Something isn't working enhancement New feature or request labels Aug 17, 2026
Comment thread jsonargparse_tests/test_postponed_annotations.py Dismissed
Comment thread jsonargparse_tests/test_typehints.py Dismissed
Comment thread jsonargparse_tests/test_dataclasses.py Dismissed
Comment thread jsonargparse_tests/test_postponed_annotations.py Dismissed
Comment thread jsonargparse_tests/test_pydantic.py Dismissed
Comment thread jsonargparse_tests/test_subclasses.py Dismissed
@mauvilsa
mauvilsa deployed to sonarcloud August 17, 2026 04:58 — with GitHub Actions Active
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2025e7b) to head (1bc9be6).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #956    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           27        27            
  Lines         8464      8600   +136     
==========================================
+ Hits          8464      8600   +136     

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

@mauvilsa
mauvilsa deployed to sonarcloud August 17, 2026 05:24 — with GitHub Actions Active
@sonarqubecloud

Copy link
Copy Markdown

@mauvilsa
mauvilsa merged commit 083fbab into main Aug 17, 2026
32 checks passed
@mauvilsa
mauvilsa deleted the improvements branch August 17, 2026 05:27
@mauvilsa mauvilsa mentioned this pull request Aug 17, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants