argparse_dataclass
argparse_dataclass copied to clipboard
Declarative CLIs with argparse and dataclasses
This PR adds two things: 1. `add_dataclass_options` becomes a public function, which fixes #58 2. I have separated the logic that infers args and kwargs for add_argument into a separate...
Thank you for this library. I would like to have an option that would allow to keep the underscores in the argument names instead of replacing them by minus signs....
draft PR to solve https://github.com/mivade/argparse_dataclass/issues/58 I wrote this before realizing there was another PR to fix the same issue [here](https://github.com/mivade/argparse_dataclass/pull/59) Note that I had to use `kwargs["default"] = field.default` for...
Hi, I would like to be able to use `_add_dataclass_options directly` in some of my code in order to be able to continue using normal argparse.ArgumentParser instances and use a...
When importing `__future__.annotations`, class annotations are evaluated lazily, and `dataclasses.Field.type` becomes `str` instead of actual type. To access its actual type, I patch the member. Ref: https://github.com/mivade/argparse_dataclass/issues/47 --- I tested...
Thanks for this project -- its really very handy. Is there's support for printing help text?
Examples are needed in the documentation to demonstrate usage of union types (see #42).
With the below script, I get an exception: ```py from __future__ import annotations from argparse_dataclass import dataclass @dataclass class MyArgs: foo: int = 0 bar: str = 'hello' baz: bool...
example code: from dataclasses import dataclass, field from argparse_dataclass import ArgumentParser from argparse import ArgumentDefaultsHelpFormatter @dataclass class FineParams: batch_size: int = field(default=300) parser = ArgumentParser(GCPFineParams, formatter_class=ArgumentDefaultsHelpFormatter) params: FineParams = parser.parse_args()...