Understanding the basics

Simon Glass sjg at chromium.org
Thu Mar 26 17:53:29 CET 2020


Hi Harald,

On Tue, 24 Mar 2020 at 04:09, Harald Seiler <hws at denx.de> wrote:
>
> Hello Simon,
>
> On Mon, 2020-03-23 at 22:10 -0600, Simon Glass wrote:
> > Hi,
> >
> > Thanks for the pointer to join this list.
> >
> > I am making progress with automation. Thank you for the help. I can
> > definitely see the potential.
> >
> > I am struggling with quite basic things in tbot.
> >
> > One thing that I think would help is to use absolute imports:
> >
> > import tbot.x.y
> >
> > And never use from xx import
> >
>
> If I am understanding you correctly with this, I totally agree:  The
> relative imports (`from .* import *`) I have used across the code-base
> need to be removed as they make following the code quite hard.  I don't
> think from-imports in general are an anti-pattern as long as they are
> strictly absolute:
>
>     from tbot.machine import linux
>
> IMO this is still easily understandable as long as module names don't
> reappear across the hierarchy (so you can immediately know what is
> referenced).  I think it also helps because you don't need to write the
> fully qualified class path (e.g. `tbot.machine.linux.build.Toolchain`)
> every time and `build.Toolchain` already contains enough information.
>
> Although, on the other hand, the hierarchy is needlessly deep at the moment
> and I am thinking about flattening it a bit (and at the same time pulling
> components which don't relate too much further apart).

Both of these sound great, looking forward to it!

>
> > Also remove everything from -the __init__.py files. Too much magic I think.
>
> I'm not sure what you mean?  The __init__.py files should all just reexport
> the names from the individual files in that module and define an `__all__`
> so glob-imports work properly.

OK, but why not have clients explicitly import what they use?

>
> The only exception I know of is the madness in
> tbot/machine/linux/__init__.py which is used to transparently provide
> compatibility aliases so old testcases and configs still work.  You can
> just assume that code does not exist though, because you shouldn't ever
> need to use any of the old names.

Can this be removed then? Perhaps keep it on a branch? Are the test
cases being migrated?

Regards,
Simon


More information about the tbot mailing list