-
Notifications
You must be signed in to change notification settings - Fork 23
[args] Inconsistent order between allowed
and allowedHelp
#845
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
These are likely sorted in order to give a stable ordering - it is derived from the keys of the We could however change this such that it sorts based on the ordering in |
Hmm, it looks like we also support not passing It also looks like we don't perform any validation that If you have some items in I also would not be shocked if some people are intentionally adding extra items to |
Another side note here, if you pass |
Sure, but AFAIK the map literal |
I see several possible ways forward here, please chime in with other ideas as well:
|
I'd add that there is this issue #123 (which is still open) and if you are actually interested in addressing it, maybe introducing some new API will be a solution for both (but this option is probably the worst in terms of effort/potential migration).
I ended up forking |
@incendial feel free to chime in with your preferred option and rationale (either from the above or an additional suggestion). I can see an argument for any of the options so any additional thoughts are helpful to guide us in a good direction here. |
If we put potential breaking changes aside, my preferred option would be to just remove the sorting. On the other hand, I have no data on how many packages/devs use this API and whether anyone else prefers or relies on this behaviour and whether the order for them is even relevant (though again, So if avoiding breaking changes is preferable, then adding a flag works fine for me. As for the number 3, I think relying on the order of P.S. Theoretically, the map can be checked if it's a map with a stable order (e.g. |
I think I prefer option 2. The fact that Dart default maps preserve key order is an assumption baked in a fair number of places now, and I think it's idiomatic to treat the key order of Map typed argument as meaningful. I think it should be safe enough to roll out the technically breaking behavior change as a non-breaking release, but I'd also be OK with a major version bump. I expect we may get some CI failures from hardcoded tests, but I do not expect any usage to be relying on the sorting in a meaningful way. Any use case that was relying on it should be able to construct a map with correctly ordered keys before passing it in. |
I am comfortable doing option 2 as well and releasing it as non-breaking. The breaking nature is fairly minor, I don't think it could make any actual application crash, just have slightly different usage text. |
It does bother me more generally how these arguments are handled but that is a different issue and I would rather not conflate the two things :) |
Closes #845 It is idiomatic to treat the key order of a Dart map as meaningful given that map literals and default Map type preserve key insertion order. It is more useful to allow the caller to decide this order than to mandate an alpha sorting by key. Callers which need this order can construct the map appropriately, and callers which prefer a different order now have the capability. Releasing as a non-breaking change since specific usage output is considered an implementation detail. This is expected to impact some CI statuf for packages with tests hardcoding a strict dependency on the output. No additional tests are necessary since updating the order in existing tests demonstrates the same behavior as adding a non-sorting specific test.
Closes #845 It is idiomatic to treat the key order of a Dart map as meaningful given that map literals and default Map type preserve key insertion order. It is more useful to allow the caller to decide this order than to mandate an alpha sorting by key. Callers which need this order can construct the map appropriately, and callers which prefer a different order now have the capability. Remove the additional list copy and iterate the map keys directly. Releasing as a non-breaking change since specific usage output is considered an implementation detail. This is expected to impact some CI statuf for packages with tests hardcoding a strict dependency on the output. No additional tests are necessary since updating the order in existing tests demonstrates the same behavior as adding a non-sorting specific test. Refactor a few null check conditions to variable assignment patterns.
Hello,
Not sure if that was ever discussed before, but
allowed
respects user defined order of options andallowedHelp
for some reason sorts them. This sorting behavior is really inconvenient, and, for example, for numbers results in:which is simply confusing for the end user.
Is there an option to make this behaviour configurable or remove it completely? Considering the inconsistency, it seems like giving the user full control over the order of items makes more sense.
The text was updated successfully, but these errors were encountered: