brentyi / tyro

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

Add support for mixed unions #96

Closed brentyi closed 9 months ago

brentyi commented 9 months ago

Closes #42

This:

import dataclasses
from typing import Union

import tyro

@dataclasses.dataclass
class Args:
    y: str

def main(x: Union[int, Args]) -> None:
    print(x)

tyro.cli(main)

Now produces: image

codecov[bot] commented 9 months ago

Codecov Report

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

Comparison is base (6140aa1) 99.57% compared to head (53b3580) 99.57%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #96 +/- ## ========================================== - Coverage 99.57% 99.57% -0.01% ========================================== Files 24 24 Lines 2096 2095 -1 ========================================== - Hits 2087 2086 -1 Misses 9 9 ``` | [Flag](https://app.codecov.io/gh/brentyi/tyro/pull/96/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/96/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Brent+Yi) | `99.57% <100.00%> (-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.