Re: [PATCH v5 06/13] scripts: generate_rust_analyzer.py: add type hints

Daniel Almeida
2025-03-31T17:09:48Z

Hi Tamir,

[snip]

> rust_project = {
> - "crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs),
> + "crates": generate_crates(
> + args.srctree,
> + args.objtree,
> + args.sysroot_src,
> + args.exttree,
> + defaultdict(
> + list,
> + {
> + crate: vals.lstrip("--cfg").split()
> + for crate, vals in map(lambda cfg: cfg.split("=", 1), args.cfgs)
> + },
> + ),
> + ),
> "sysroot": str(args.sysroot),
> }
>
>
> --
> 2.49.0
>

I found `args_crates_cfgs()` a lot easier to understand, but I guess this is a
matter of taste. I also find that this `defaultdict()` call slightly pollutes
the surrounding code, but again, that might be just me.

Regardless, running `mypy` still passes, and there is no change to the output.

Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>

— Daniel