Feature or enhancement
Currently, we have a lot of pattern of the form:
with EnvironmentVarGuard() as env:
if no_c in env:
env.unset(no_c)
if no_d in env:
env.unset(no_d)
for ev in {no_a, no_b}:
if ev in env:
env.unset(ev)
I think it makes sense to have something like this:
with EnvironmentVarGuard() as env:
env.unset(no_a, no_b, no_c, no_d) # unset many vars at once
or to also provide a decorator-based approach when the values to set/unset are statically known.
Features
Some optional features that I rejected after looking at the use cases:
I plan to create a PR today or tomorrow to illustrate the new interface.
EDIT: no need to the support for setting multiple variables at once because EnvironmentVarGuard is a mapping, so it has .update() which does the trick.
Linked PRs
See #131277 (comment) for the version labels rationale and #131280 (comment) for the backporte rationale.
Feature or enhancement
Currently, we have a lot of pattern of the form:
I think it makes sense to have something like this:
or to also provide a decorator-based approach when the values to set/unset are statically known.
Features
env.unset(k1, k2, ...)Some optional features that I rejected after looking at the use cases:
I plan to create a PR today or tomorrow to illustrate the new interface.
EDIT: no need to the support for setting multiple variables at once because
EnvironmentVarGuardis a mapping, so it has.update()which does the trick.Linked PRs
EnvironmentVarGuardto unset more than one environment variable at once #131280See #131277 (comment) for the version labels rationale and #131280 (comment) for the backporte rationale.