RE: [External] - Re: [libgpiod][PATCH 01/22] bindings: python: clean up imports and exports

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bart,

> -----Original Message-----
> From: Bartosz Golaszewski <brgl@xxxxxxxx>
> Sent: Tuesday, October 8, 2024 6:16 AM
> To: Vincent Fazio <vfazio@xxxxxxxxxxx>
> Cc: linux-gpio@xxxxxxxxxxxxxxx; vfazio@xxxxxxxxx
> Subject: [External] - Re: [libgpiod][PATCH 01/22] bindings: python: clean up
> imports and exports
> 
> On Fri, Sep 27, 2024 at 9:05 PM Vincent Fazio <vfazio@xxxxxxxxxxx> wrote:
> >
> > Remove unused imports and sort the remainder following isort rules.
> >
> > Update submodules to use lists for `__all__` for ease of re-exporting
> > public classes from within gpiod.
> >
> > Also, fix instances where `line` wasn't imported via a relative import.
> > The library now consistently uses relative imports for submodules.
> >
> > Signed-off-by: Vincent Fazio <vfazio@xxxxxxxxxxx>
> > ---
> 
> This definitely improves the output of help(gpiod) but I was under the
> impression that we discussed re-exporting the definitions from gpiod.line
> directly from gpiod and I argued that this isn't really a good idea as they do fall
> under the umbrella of "line" definitions and should be imported from
> gpiod.line explicitly. I thought it would work more like:
> 
> >>> from gpiod import *
> # now we also imported line
> >>> line.Direction.OUTPUT
> <Direction.OUTPUT: 3>
> 
> Is there any reason for not doing it this way?


It's mostly just a convenience/cosmetic thing.

All of the other classes, including the Exceptions, were exported, I thought
maybe the intent was to expose everything and that the line Enums were simply
an oversight. I misinterpreted our conversation on GH:

  Me: Right now, the objects in `gpiod.line` are hidden behind `line.X` or
    require explicit import via `from gpiod.line import X, Y`

  You: And that is an omission from my side.

The main benefit is that all gpiod classes are directly available from the main
module so consumers don't have to hunt down the import path for the line Enums
or have extended type hints a la:

  def fn(arg: gpiod.line.Value) -> None: ...

or

  def fn(arg: line.Value) -> None: ...

It's cosmetic and can be solved with an additional import so isn't a huge deal.

I can certainly restore the previous behavior for these Enums.
.

> 
> Bart
> CAUTION: This email originated from outside of the organization. Do not click
> links or open attachments unless you recognize the sender and know the
> content is safe.

-Vincent




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux