omni-us / jsonargparse

Implement minimal boilerplate CLIs derived from type hints and parse from command line, config files and environment variables
https://jsonargparse.readthedocs.io
MIT License
314 stars 42 forks source link

[MRG] Support `TypedDict` #494

Closed PierreGtch closed 4 months ago

PierreGtch commented 4 months ago

Hi, Thanks for this great library!

What does this PR do?

This PR adds support to TypedDicts. Closes #457

Before submitting

I updated the adapt_typehints function, added tests in test_typehints.py, and updated the CHANGELOG.rst. Please tell me if I missed anything :)

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (af37f08) to head (f112a41).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #494 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 21 21 Lines 6102 6116 +14 ========================================= + Hits 6102 6116 +14 ``` | [Flag](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | Coverage Δ | | |---|---|---| | [py3.10](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `87.23% <100.00%> (+0.02%)` | :arrow_up: | | [py3.10_all](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `98.64% <100.00%> (+<0.01%)` | :arrow_up: | | [py3.10_pydantic1](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `49.06% <31.25%> (-0.05%)` | :arrow_down: | | [py3.10_pydantic2](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `48.83% <31.25%> (-0.05%)` | :arrow_down: | | [py3.10_types](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `98.65% <100.00%> (+<0.01%)` | :arrow_up: | | [py3.11](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `87.21% <100.00%> (+0.02%)` | :arrow_up: | | [py3.11_all](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `98.64% <100.00%> (+<0.01%)` | :arrow_up: | | [py3.11_types](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `98.65% <100.00%> (+<0.01%)` | :arrow_up: | | [py3.12](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `87.36% <100.00%> (+0.02%)` | :arrow_up: | | [py3.12_all](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `98.64% <100.00%> (+<0.01%)` | :arrow_up: | | [py3.12_types](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `98.65% <100.00%> (+<0.01%)` | :arrow_up: | | [py3.7](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `87.77% <31.25%> (-0.14%)` | :arrow_down: | | [py3.7_all](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `99.25% <31.25%> (-0.17%)` | :arrow_down: | | [py3.7_types](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `99.25% <31.25%> (-0.17%)` | :arrow_down: | | [py3.8](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `87.94% <93.75%> (+0.02%)` | :arrow_up: | | [py3.8_all](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `99.41% <93.75%> (+<0.01%)` | :arrow_up: | | [py3.8_types](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `99.41% <93.75%> (+<0.01%)` | :arrow_up: | | [py3.9](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `87.78% <93.75%> (+0.02%)` | :arrow_up: | | [py3.9_all](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `99.28% <93.75%> (+<0.01%)` | :arrow_up: | | [py3.9_types](https://app.codecov.io/gh/omni-us/jsonargparse/pull/494/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `99.29% <93.75%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

PierreGtch commented 4 months ago

Ready for review :)

sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

PierreGtch commented 4 months ago

All done @mauvilsa :)