brentyi / tyro

CLI interfaces & config objects, from types
https://brentyi.github.io/tyro
MIT License
467 stars 23 forks source link

Fix: `tyro.cli` description #124

Closed kevinddchen closed 7 months ago

kevinddchen commented 7 months ago

Fixes #123.

An unintended side-effect of #118 introduced a regression that broke the tyro.cli(description=...) field for hierarchical configs. This was due to an extraneous setting of the argparse.ArgumentParser.description field, which was causing the description to be set by the description of a leaf node in the tree.

The description was initially set in the .apply() method here: https://github.com/brentyi/tyro/blob/30803e8a4ee871693f7b021be84265780ddc0146/src/tyro/_parsers.py#L201

Later, there is a call into the .apply_args() method that sets the description again: https://github.com/brentyi/tyro/blob/30803e8a4ee871693f7b021be84265780ddc0146/src/tyro/_parsers.py#L241

This is problematic after #118 because we now recurse into the .apply_args() method: https://github.com/brentyi/tyro/blob/30803e8a4ee871693f7b021be84265780ddc0146/src/tyro/_parsers.py#L291

I have a strong feeling I am overlooking something. I will see if tests pass or not. I can also add a test if you want to check the description field.

codecov[bot] commented 7 months ago

Codecov Report

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

Comparison is base (30803e8) 99.58% compared to head (24cf573) 99.58%. Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #124 +/- ## ========================================== - Coverage 99.58% 99.58% -0.01% ========================================== Files 24 24 Lines 1949 1948 -1 ========================================== - Hits 1941 1940 -1 Misses 8 8 ``` | [Flag](https://app.codecov.io/gh/brentyi/tyro/pull/124/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Brent+Yi) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/brentyi/tyro/pull/124/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Brent+Yi) | `99.58% <ø> (-0.01%)` | :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=Brent+Yi#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.