-
Notifications
You must be signed in to change notification settings - Fork 30
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
Determine argument type automatically from default #22
Comments
Care to expand on that? What would be your use case? |
Sure, sorry. It’s a common use case for me: I want to specify a non-string default value for a positional argument, and have the argument parsed as the correct data type, without having to provide unnecessary/redundant information in the attribute. For example,
this:
def main(size: “The size of the thing” = 10):
…
is much easier to write than
def main(size: (“The size of the thing”, “positional”, None, int) = 10):
...
In my mind, the first is also easier to understand, as I’d assume that a parameter with an integer default always expects an integer argument.
Another alternative would be to allow the attribute to be a dict rather than a tuple, so I could specify only fields I need:
def main(size: dict(help=“The size of the thing”, type=int) = 10):
…
Which is at least easier to parse, since now I don’t have to know the order of the fields in the attribute tuple to understand it, but still, in my opinion, more verbose than necessary.
…On Feb 15, 2017, at 11:03 PM, Michele Simionato ***@***.***> wrote:
Care to expand on that? What would be your use case?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
This is actually a good idea. I will keep it in mind, but I do not known when I will have time to work on it. |
Thanks. If I have time I will submit a pull request.
… On Feb 16, 2017, at 11:59 AM, Michele Simionato ***@***.***> wrote:
This is actually a good idea. I will keep it in mind, but I do not known when I will have time to work on it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#22 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAHrnqPCXWY7YrXMj2M_rphV8g3yrBSkks5rdIB1gaJpZM4MCXTr>.
|
This was actually implemented in plac 1.0, one year ago, but I forgot to close the issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: