Understanding the basics
Harald Seiler
hws at denx.de
Thu Mar 26 18:13:25 CET 2020
Hello Simon,
On Thu, 2020-03-26 at 10:53 -0600, Simon Glass wrote:
> 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?
It is not for me, but for downstream people who want to use glob imports. I'd
never use them myself and the CI is configured to reject any patch which does,
but some people like glob imports and for them, these few lines are included ...
> > 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?
It will definitely be removed in the near future!
> Regards,
> Simon
--
Harald
More information about the tbot
mailing list