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

Feature request: Allow passing a third-party dataclass #11

Open caioariede opened 1 week ago

caioariede commented 1 week ago

Example:

from some_library import SomeDataclass
import dataclass_click

@dataclass_click(SomeDataclass)
def cmd(...):
    ...

Can still be customizable with:

@dataclass
class SomeDataclassExtended(SomeDataclass):
    some_field = Annotated[...]
couling commented 1 week ago

Are you able to give a concrete example of a third party class that you’d like to work, that doesn’t. At first glance, this should already be possible.

caioariede commented 1 week ago

After playing a little more with it, it really appears to be possible. I was able to do it by inheriting the dataclass and re-declaring the fields with option/Annotated - is that correct? If so, is there a way to not need to inherit/redeclare fields?