-
Notifications
You must be signed in to change notification settings - Fork 191
Allowed to request processing of all possible values in Set #547
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
Conversation
|
Needs tests, Python 2 supers (for now). Also |
By definition
I have considered that, but it can either break existing apps (if we ship |
|
Integrated the functionality into |
| a list. Accepts ``True``, ``False``, or a string for the separator | ||
| """ | ||
| :param all_markers: when a user inputs any value from this set, it is considered that | ||
| he requested iteration over all values. By default `all_markers` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| he requested iteration over all values. By default `all_markers` | |
| they requested iteration over all values. By default `all_markers` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://stallman.org/articles/genderless-pronouns.html
So, in order to have they (if one strictly wants to avoid possibility of stirring up SJ-hornets' nests), when a user inputs should become when users input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| he requested iteration over all values. By default `all_markers` | |
| to be a request for iteration over all values. By default `all_markers` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and also remove "that" from the line above)
| self.case_sensitive = kwargs.pop("case_sensitive", False) | ||
| all_markers = kwargs.pop("all_markers", None) | ||
| if all_markers is None: | ||
| all_markers = {"*", "all"} - set(values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| all_markers = {"*", "all"} - set(values) | |
| all_markers = {"*"} - set(values) |
Adding the English string "all" by default seems a little likely to be suprising, and possibly conflicting with potential entries. I think it would be better to default to "*" then provide an example for how to set {"*", "all"}.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For "*", as you have noticed, one has to type quotes. It is not very convenient (it is the same amount of characters, but to type a " one has to press shift, it is also a "mode switch "from letters to punctuation"), so I usually use "all".
Adding the English string "all" by default seems a little likely to be suprising
I don't think so: if one wants a string "all" in an arg of type "Set", it explicitly says that he wants all the values.
If you mean that the problem is that the string is English that "discriminates" against other languages, I think that having the universal same string for all the languages that doesn't depend on a locale outweights the possibility of mismatch between languages of other enum values and outweights the variant not having it at all. Making a language-dependent marker will cause only issues and increase cognitive load in using it. Not having a default one will cause users to invent own ones, which again will increase cognitive load of using it.
, and possibly conflicting with potential entries.
Introducing any default string can be conflicting. That's why the line to which you have left this comment exists - to avoid the conflicts automatically. If user-provided Set doesn't have all and *, then they will be used as markers for all the values. If user explicitly has opted in, then he fully controls that field and it is he is responsible for solving for possible conflicts.
| """ | ||
| :param all_markers: when a user inputs any value from this set, it is considered that | ||
| he requested iteration over all values. By default `all_markers` | ||
| are {"*", "all"}.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| are {"*", "all"}.""" | |
| are {"*"}; you can set it to {"all", "*"}, for example.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you suggest it be changed, if we resolve conflicts automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plumbum comes with built-in translations for German, French, Dutch, and Russian. Either this string needs to support translations, or it should be language agnostic. A local dependent default is poor (as you noted), so why not just use the symbol? Also, if the user uses all-caps for their options, then this will be lower case, which is weird. Why not just use "*" as the default string (exactly the same number of characters as all) and let the user decide if they like "all" or something else?
Also there's the issue of being misleading. "all" is much more likely to look like a normal option that "*" is; and it's not a normal option, it just selects all the others.
I don't think anyone else has an "all/*" like option. Does anyone else? I checked Click, doesn't seem to have this sort of select-all feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this show up in the help anywhere?
If you really want to make "all" part of the default, I'd take a tie breaker opinion. @tomerfiliba perhaps? Or any other person who has committed anything.
…ible values in a `Set`.
No description provided.