[PATCH v3 3/5] patman: Make most bool arguments BooleanOptionalAction

Simon Glass sjg at chromium.org
Sun Jul 17 10:17:12 CEST 2022


Hi Doug,

On Sat, 16 Jul 2022 at 11:47, Doug Anderson <dianders at chromium.org> wrote:
>
> Hi,
>
> On Sat, Jul 16, 2022 at 4:55 AM Simon Glass <sjg at chromium.org> wrote:
> >
> > Hi Doug,
> >
> > On Thu, 7 Jul 2022 at 09:26, Douglas Anderson <dianders at chromium.org> wrote:
> > >
> > > For boolean arguments it's convenient to be able to specify both the
> > > argument and its opposite on the command line. This is especially
> > > convenient because you can change the default via the settings file
> > > and being able express the opposite can be the only way to override
> > > things.
> > >
> > > Luckily python handles this well--we just need to specify things with
> > > BooleanOptionalAction. We'll do that for all options except
> > > "full-help" (where it feels silly). This uglifies the help text a
> > > little bit but does give maximum flexibility.
> > >
> > > Signed-off-by: Douglas Anderson <dianders at chromium.org>
> > > Tested-by: Brian Norris <briannorris at chromium.org>
> > > Reviewed-by: Brian Norris <briannorris at chromium.org>
> > > Reviewed-by: Simon Glass <sjg at chromium.org>
> > > ---
> > >
> > > (no changes since v2)
> > >
> > > Changes in v2:
> > > - Fix doc string for --ignore-bad-tags
> > >
> > >  tools/patman/main.py | 55 ++++++++++++++++++++++----------------------
> > >  1 file changed, 28 insertions(+), 27 deletions(-)
> >
> > Sadly this patch triggers an error:
> >
> > Traceback (most recent call last):
> >   File "./tools/patman/patman", line 9, in <module>
> >     from argparse import ArgumentParser, BooleanOptionalAction
> > ImportError: cannot import name 'BooleanOptionalAction' from
> > 'argparse' (/usr/lib/python3.8/argparse.py)
> >
> >
> > I've dropped it and the next one. Can you please take a look?
>
> Ugh. I hadn't noticed that it was added in python 3.9. I guess we
> don't want to require python 3.9+? Python 3.9 was released October
> 2020...

Not yet! It might be possible to do a little compatibility thing. We
do sometimes have code that does things the old way and the new way.
But it might be too intrusive in this case?

Regards,
Simon


More information about the U-Boot mailing list