On 12/4/26 10:26, Pavee Zheng via B4 Relay wrote: > From: Pavee Zheng > > Ruff's B006 (mutable-argument-default) lint flags using mutable data > structures such as {} as default argument values because Python > evaluates default arguments once at function definition time and shares > the same object across all calls, so in-place mutations persist across > subsequent calls. > > Conf._run_conf() and Conf._allconfig() both declare extra_env={} and > mutate extra_env in place: > > - Conf._allconfig() assigns extra_env['KCONFIG_ALLCONFIG'] when > all_config is set. No existing test currently passes a non-None > all_config to allyesconfig(), allmodconfig(), allnoconfig(), or > alldefconfig(), so this does not trigger a failure today, but a > future caller doing so would leave a stale KCONFIG_ALLCONFIG entry > in the shared default dictionary for subsequent calls in the same > pytest session. > - Conf._run_conf() assigns extra_env['srctree'], mutating both its > default dictionary and caller-owned dictionaries passed via > extra_env (such as warn_changed_input in > scripts/kconfig/tests/warn_changed_input/__init__.py). > > As a defensive cleanup and readability improvement, default extra_env > to None in both methods. In _run_conf(), merge extra_env into the local > env dictionary and set env['srctree'] there instead of mutating > extra_env. In _allconfig(), build a fresh local dictionary copy before > inserting KCONFIG_ALLCONFIG. > > Signed-off-by: Pavee Zheng Tested-by: Julian Braha Reviewed-by: Julian Braha