couling / dataclass-click

Wrapper for pallets/click that uses dataclasses instead of kwargs
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

Improved inference handling for multi types and nargs types #8

Closed couling closed 5 months ago

couling commented 5 months ago

There was previously a bug with inference handling where nargs=-1 or multuple=True or is_flag should mean not required, but this was not being assessed. Required inference is now much more reliable.

Type inference handling where nargs=-1 or multiple=True now knows to unbox the tuple[foo, ...] to foo. Likewise inference handling for nargs > 1 also knows to unbox tuple types.

Eg: this now works:

@dataclass
class Foo:
    bar: Annotated[tuple[int, str], argument(nargs=2)]