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

From: Tamir Duberstein

Date: Tue Apr 28 2026 - 11:53:25 EST


On Tue, Apr 28, 2026 at 10:24 AM Jesung Yang <y.j3ms.n@xxxxxxxxx> wrote:
>
> On Tue, Apr 28, 2026 at 1:56 PM Tamir Duberstein <tamird@xxxxxxxxxx> wrote:
> > On Tue, Apr 28, 2026 at 9:36 AM Jesung Yang <y.j3ms.n@xxxxxxxxx> wrote:
> > > Other than that, given that declaring all imports at the top is not
> > > mandatory, I wonder if we could just conditionally import `ParamSpec` as
> > > follows:
> > >
> > > ```
> > > from typing import Any, Callable, TypeVar
> > >
> > > T = TypeVar('T')
> > > if sys.version_info < (3, 10):
> > > def wrapper(func: Callable[..., T]) -> Callable[..., T]:
> > > def wrapper(*args: Any, **kwargs: Any) -> T:
> > > return func(*args, **kwargs)
> > > return wrapper
> > > else:
> > > from typing import ParamSpec
> > >
> > > P = ParamSpec('P')
> > > def wrapper(func: Callable[P, T]) -> Callable[P, T]:
> > > def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
> > > return func(*args, **kwargs)
> > > return wrapper
> > > ```
> > >
> > > In this case, we don't need the `t.` prefix.
> >
> > This would work. It introduces the need to be careful about unused
> > imports. Do you prefer this?
>
> Yes, as long as you're also OK with it :)

Sure. I still think this patch is tidier but will shelve it for now.