Skip to content

Commit

Permalink
Release candidate 3 with initial support for dataclasses
Browse files Browse the repository at this point in the history
(cherry picked from commit bae439c)
  • Loading branch information
fleonce committed Nov 27, 2024
1 parent 166ea59 commit f420512
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions with_argparse/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ def set_config(key: str, state: bool):
config[key] = state


def with_dataclass(
*,
dataclass=None,
):
def wrapper(fn):
@functools.wraps(fn)
def inner(*inner_args, **inner_kwargs):
if not is_enabled():
return fn(*inner_args, **inner_kwargs)

parser = WithArgparse(
(dataclass, fn),
)
return parser.call(inner_args, inner_kwargs)
return inner
return wrapper


@overload
def with_argparse(
*,
Expand Down

0 comments on commit f420512

Please sign in to comment.