Re: [PATCH] scripts: generate_rust_analyzer.py: reduce import noise

From: Tamir Duberstein

Date: Mon Apr 27 2026 - 10:53:45 EST


On Mon, Apr 27, 2026 at 10:38 AM Link Mauve <linkmauve@xxxxxxxxxxxx> wrote:
>
> Hi Tamir,
>
> On Mon, Apr 27, 2026 at 10:23:44AM -0400, Tamir Duberstein wrote:
> > Use `import typing as t` to avoid having to list each imported symbol
> > whenever it is added.
>
> This isn’t really idiomatic Python though, every other Python project
> I’ve worked on listed all types they import from typing the way this was
> done previously.
>
> I think the reasoning is that it’s more important to keep the location
> directly in the code more readable, at the cost of making the import
> lines slightly longer.
>
> But if this is a regular kernel practice, please disregard my comment!

Thanks for taking a look. I'm not aware of regular kernel practice in
this area. This patch is motivated by the discussion in
https://lore.kernel.org/all/CAJ-ks9=p3i5xbnDojJ7QopmUanec0ZPZ_x3_zD0Csyad5L7FEA@xxxxxxxxxxxxxx/
where symbols used from `typing` may become conditional, which would
complicate declaring all the imports at the top.