Skip to content

Support for parameter descriptions from Annotated[..., Doc("...")] - #1030

Merged
mauvilsa merged 2 commits into
mainfrom
annotated-doc-descriptions
Oct 29, 2026
Merged

mauvilsa merged 2 commits into
mainfrom
annotated-doc-descriptions

Conversation

@mauvilsa

Copy link
Copy Markdown
Owner

What does this PR do?

Adds support for parameter descriptions given as Annotated[..., Doc("...")] (PEP 727), e.g. using typing_extensions.Doc or any compatible Doc class that has a documentation attribute. The descriptions are shown in the help and take precedence over docstrings, so they work without the docstrings extra. This applies to functions, classes, dataclasses, pydantic models, TypedDicts and NamedTuples. The Doc metadata is removed from the type, while any other Annotated metadata is kept.

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?
  • [n/a] 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 the enhancement New feature or request label Oct 29, 2026
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The PR changes generated parameter help across several supported input types.

The PR appears safe to merge, with two non-blocking gaps in how descriptions reach the help.

Findings

  1. P2 Optional keys lose descriptions ▶
  2. P2 Empty descriptions keep old text ▶

Summary

Adds parameter descriptions from Annotated[..., Doc("...")].

  • Parameter help can use descriptions stored in Annotated metadata.

Reviews (1) · Last reviewed commit: "Support for parameter descriptions from ..." · Reviewed by Greptile

Comment thread jsonargparse/_optionals.py Resolved
Comment thread jsonargparse/_parameter_resolvers.py Resolved
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1030   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines        10020     10046   +26     
=========================================
+ Hits         10020     10046   +26     

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

@sonarqubecloud

Copy link
Copy Markdown

@mauvilsa
mauvilsa merged commit b8c3925 into main Oct 29, 2026
35 checks passed
@mauvilsa
mauvilsa deleted the annotated-doc-descriptions branch October 29, 2026 06:30

This branch was previously deployed

1 inactive deployment
sonarcloud — 1f4c59db Deployed Oct 29, 2026 by mauvilsa via sonarcloud #1022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant