swansonk14/typed-argument-parser

tapify help string order is random

swansonk14 opened this issue · 1 comments

When tapify is used and run with -h, the arguments are printed in a random order. They should be printed in the same order as they are listed in the function or class (or docstring).

Hi @swansonk14,

The help string order was deterministic in tapify.

However, some of your code returned a subclass of Tap that included the annotations information. Instantiating that class resulted in a help string with arguments that were randomly ordered. The randomness came from the unioning of dictionary keys, which downcasts the ordered data structure dict_keys data structure to an unordered set.

Instead, we now merge the dictionaries and then extract the keys. You can see the before and after here: 70137fd.

In the future, this means that we can incorporate code that separates out the creation of a subclass of Tap from its instantiation. This is useful when creating a large Tap comprising multiple other Tap objects added via add_parser.

--JK