[PATCH] rtemstoolkit/mailer.py: Fix option ordering for add_arguments

Alex White alex.white at oarcorp.com
Thu May 6 14:18:46 UTC 2021


On Wed, May 5, 2021 at 10:15 PM Chris Johns <chrisj at rtems.org> wrote:
>
> On 6/5/21 4:49 am, Gedare Bloom wrote:
> > On Wed, May 5, 2021 at 9:16 AM Alex White <alex.white at oarcorp.com> wrote:
> >>
> >> On Wed, May 5, 2021 at 9:47 AM Gedare Bloom <gedare at rtems.org> wrote:
> >>>
> >>> Why?
> >>
> >> To prevent the '--mail' and '--use-gitconfig' options from being added more than once to the ArgumentParser in add_arguments.
> >>
> > How does that happen?
> >
> > I'm not trying to be frustrating (just annoying). I want to be sure
> > we're using the right solution for the right problem, and not just
> > putting a bandaid over something so it works while we hide some
> > underlying concerns.

It happened because I did not know about the lack of a dictionary key ordering guarantee in Python (at least before 3.6 I believe) and because I forgot to update the start index for iterating the keys. I will take Chris's approach below.

>
> Gedare, I am agree. I think there maybe another simpler solution.
>
> Why not make the list() be something like ...
>
>   no_add = ['--mail', '--use-gitconfig']
>   for o in [opt for opt in list(_options) if not in no_add]:
>     ..
>
> ... or something like that?

This seems more reliable as it avoids the magic number in the loop and should avoid introducing problems like this in the future. I'll get a v2 out with this added.

Thanks,

Alex

>
> Chris
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210506/2ce30398/attachment-0001.html>


More information about the devel mailing list