-
Notifications
You must be signed in to change notification settings - Fork 15
Printing default values as well as help from the command line #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I see from here that this cannot apparently be changed due to the consequences it has on the But after having created a fork and testing it out with the changes above and removing the assignment of default key value to What exactly are the consequences of not using the sentinel class value of |
The thought behind having the dataclass handle the default value was to make sure that creating an instance of the dataclass outside of the Maybe the following example will be helpful in explaining what I feel needs to be avoided. In older versions this package, the That being said, I am not able to think of a use case where having the I have a draft PR open if you want to review and see if this change works for you. I also would like to think about it a few more days to be sure I am not missing something and obviously get mivade's opinion. It is PR #66 |
I'm with you. I'm going to be honest, I'm not too sure what the purpose of the default_factory is (in this application) as long as you plan to provide a default value, it's purpose subsides right? I too would be worried about additional methods like post_init causing unexpected behaviour. It's not directly related to this specific issue, but I was actually researching the behaviour of dataclasses when using inheritance, in preparation for using it with this library. you can find the discussion here it may be helpful with illuminating the behaviour you're concerned about. |
I've not ever actually used help formatters with argparse. Is there any reason we couldn't just provide our own that does this? |
This was my first time using it too. I was pleasantly surprised at how closely it worked straight out the box with this library. Defining one specific to this library could be done, but I personally would probably opt for the easier option and superficially I thought it was the above change but it may not be if you don't want to constrain people to using the argparse library in specific ways like I'm getting the impression it would do with my suggestion. |
I am trying to use the
ArgumentDefaultsHelpFormatter
class from the originalargparse
library to enhance the displayed help information when using theArgumentParser
class from theargparse_dataclass
library. Suppose I run the followingscript.py
with the help --h
- flagI would expect the terminal output to be like:
but its actually like:
Does anyone know how to rectify this behavior?
EDIT
As I am seeking help from multiple places on the subject, the other being a stack overflow post, it was pointed out that this behavior is due to these lines in the source code
could potentially editing these lines in the source code from
to
stop this behavior from happening?
The text was updated successfully, but these errors were encountered: