Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change (or at least document) surprising behavior parsing env var when explicitly set to empty string #71

twosigmajab opened this issue Apr 25, 2019 · 2 comments · Fixed by #73


Copy link

commented Apr 25, 2019

Environs users I'm supporting just hit this:

➜ cat config/foo.env 

➜ . config/foo.env

➜ python3
>>> from environs import Env
>>> env = Env()
>>> env.float("MYFLOAT")
>>> env.bool("MYBOOL")
>>> env.str("MYSTR")

What? Expected empty string, as explicitly set:

>>> from os import environ
>>> environ["MYSTR"]

This violates reasonable assumptions that the type of the value returned by is always foo, as is otherwise consistent with env.bool,, env.float, etc.:

>>> isinstance(env.str("MYSTR"), str)

In this use case, the user should not need to know what a marshmallow.missing is, as it is an implementation detail, and should get back the explicitly set value of empty string rather than needing special logic that knows how to deal with marshmallow.missing.

If the current behavior cannot be changed e.g. for compatibility reasons, it should at least be documented, as this seems like a common use case.

Happy to submit a PR if that would be of interest. Thanks!


This comment has been minimized.

Copy link

commented Apr 26, 2019

This does appear to be a bug; I'd expect an empty string to be returned instead of marshmallow.missing.

I can't look into it today, so would definitely appreciate a PR.


This comment has been minimized.

Copy link

commented Apr 27, 2019

I'll prepare a PR next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.