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

Fixes for non-stdlib dataclass-like types #480

Closed nkrishnaswami closed 4 months ago

nkrishnaswami commented 5 months ago

What does this PR do?

This PR includes a few small, related fixes for non-stdlib (possibly annotated) dataclasses and 3.12-style type aliases:

Before submitting

nkrishnaswami commented 5 months ago

Hmm, seeing errors on pydantic < 2.6; how far back do you need to support?

nkrishnaswami commented 5 months ago

Hmm, seeing errors on pydantic < 2.6; how far back do you need to support?

Sorted this out for 2.0+, but I am not sure how to set up the Pydantic v1 test environment

nkrishnaswami commented 5 months ago

For the moment, I see that there is a test failing in test-py310-pydantic-v1. ... Please make sure that the test passes because there is no plan yet to drop support for pydantic v1.

@mauvilsa Gotcha. I was having trouble running the tests in my virtual env, but I found the commands to use in the circleci config; I'll get this fixed shortly!

codecov[bot] commented 5 months ago

Codecov Report

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

Project coverage is 100.00%. Comparing base (9906794) to head (7ab0c80).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #480 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 21 21 Lines 6027 6090 +63 ========================================= + Hits 6027 6090 +63 ``` | [Flag](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/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/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `87.17% <50.00%> (-0.45%)` | :arrow_down: | | [py3.10_all](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `98.63% <91.02%> (-0.09%)` | :arrow_down: | | [py3.10_pydantic1](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `49.14% <60.25%> (+0.23%)` | :arrow_up: | | [py3.10_pydantic2](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `48.89% <62.82%> (+0.26%)` | :arrow_up: | | [py3.10_types](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `98.65% <92.30%> (-0.07%)` | :arrow_down: | | [py3.11](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `87.15% <50.00%> (-0.45%)` | :arrow_down: | | [py3.11_all](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `98.63% <91.02%> (-0.09%)` | :arrow_down: | | [py3.11_types](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `98.65% <92.30%> (-0.07%)` | :arrow_down: | | [py3.12](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `87.30% <57.69%> (-0.30%)` | :arrow_down: | | [py3.12_all](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `98.63% <91.02%> (-0.09%)` | :arrow_down: | | [py3.12_types](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `98.65% <92.30%> (-0.07%)` | :arrow_down: | | [py3.7](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `87.88% <58.97%> (-0.30%)` | :arrow_down: | | [py3.7_all](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `99.42% <93.58%> (-0.07%)` | :arrow_down: | | [py3.7_types](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `99.42% <94.87%> (-0.05%)` | :arrow_down: | | [py3.8](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `87.89% <50.64%> (-0.44%)` | :arrow_down: | | [py3.8_all](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `99.40% <90.90%> (-0.10%)` | :arrow_down: | | [py3.8_types](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `99.40% <92.20%> (-0.08%)` | :arrow_down: | | [py3.9](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `87.73% <49.35%> (-0.46%)` | :arrow_down: | | [py3.9_all](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `99.27% <90.90%> (-0.10%)` | :arrow_down: | | [py3.9_types](https://app.codecov.io/gh/omni-us/jsonargparse/pull/480/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=omni-us) | `99.29% <92.20%> (-0.08%)` | :arrow_down: | 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.

mauvilsa commented 5 months ago

@mauvilsa Gotcha. I was having trouble running the tests in my virtual env, but I found the commands to use in the circleci config; I'll get this fixed shortly!

You don't need to look at the circleci config to figure out how to run tests. In the CONTRIBUTING.rst guideline it is recommended that you setup pre-commit. And the pydantic v1 tests are run as part of the pre-push hooks. Also there it is explained how to manually run them.

nkrishnaswami commented 5 months ago

@mauvilsa got the tests and CI passing! Thanks!

nkrishnaswami commented 4 months ago

It is looking good. But some work is needed. See the comments.

Thanks for the feedback! I believe I have address these in the latest commit(s).

nkrishnaswami commented 4 months ago

That last set of fixes broke nested dataclasses on 3.12, and init=False on 3.7 for Pydantic dataclasses. (The version dependency is a surprise). I'll take a look at those tonight (UTC-5)

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