When a prefix is set, Env.get_value uses the prefixed name, but Env.__contains__ still checks only the raw key.
Current behavior
def __contains__(self, var: _str):
return var in self.ENVIRON
Repro
import environ
env = environ.Env()
env.prefix = "DJANGO_"
env.ENVIRON["DJANGO_DEBUG"] = "1"
env.get_value("DEBUG") # returns "1"
"DEBUG" in env # returns False
Expected
"DEBUG" in env should return True in this case, consistent with get_value (or simple call).
Suggested fix
def __contains__(self, var: _str):
return f"{self.prefix}{var}" in self.ENVIRON
Happy to open a PR with this change and a test covering prefixed membership.
When a prefix is set, Env.get_value uses the prefixed name, but
Env.__contains__still checks only the raw key.Current behavior
Repro
Expected
"DEBUG" in envshould returnTruein this case, consistent withget_value(or simple call).Suggested fix
Happy to open a PR with this change and a test covering prefixed membership.