tox icon indicating copy to clipboard operation
tox copied to clipboard

tox needs an option to unset environment variables to complement passenv

Open ssbarnea opened this issue 4 years ago • 6 comments

Currently there is no option to tell tox to passenv FOO_* with exceptions FOO_BAR and if you are unlikely enough to have to deal with a tool for which unset and set-as-empty-string has different behavior you are kinda out of options.

Instead of adding new options it could be easier if we would have magic value on setenv which unsets variables, taking precendence of use of wildcard on passwenv.

I initially asked on https://stackoverflow.com/questions/57293456/how-do-i-unset-an-environment-variable-with-python-tox but apparently there is no way to achieve that now.

ssbarnea avatar Aug 02 '19 14:08 ssbarnea

Not sure I see this under core, if anything would need some time as a plugin to mature and maybe after then 🤔

gaborbernat avatar Aug 02 '19 14:08 gaborbernat

@gaborbernat it is clearly related to passenv and setenv and I do not see any reasons for not being address by them. How is implemented is a detail, but it matters to allow user to blacklist.

If wildcards from passenv could accept regexes we could add a negative match.

Maybe a {omit} tag could make sense?

Or maybe you have another idea?

ssbarnea avatar Aug 02 '19 14:08 ssbarnea

I would prefer it outside of core just because of seems rare and complicated enough that does not warrant complicating the interface for new users.

gaborbernat avatar Aug 02 '19 15:08 gaborbernat

On reflection here for this, we'd want a disallow_pass_env that gets applied just before set_env (so post glob expansion).

gaborbernat avatar Jan 13 '22 10:01 gaborbernat

@gaborbernat To avoid adding a new configuration item, I was wondering if this could be implemented using a prefixed entry in passenv or setenv like !FOO or -FOO for the values that are not expected to be passed.

ssbarnea avatar Apr 03 '23 14:04 ssbarnea

I'd prefer a new configuration than this conflating syntax. PR welcome.

gaborbernat avatar Apr 03 '23 17:04 gaborbernat