Environs users I'm supporting just hit this:
➜ cat config/foo.env
MYINT="0"
MYFLOAT="0.0"
MYBOOL="False"
MYSTR=""
➜ . config/foo.env
➜ python3
...
>>> from environs import Env
>>> env = Env()
>>> env.int("MYINT")
0
>>> env.float("MYFLOAT")
0.0
>>> env.bool("MYBOOL")
False
>>> env.str("MYSTR")
<marshmallow.missing>
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 env.foo is always foo, as is otherwise consistent with env.bool, env.int, env.float, etc.:
>>> isinstance(env.str("MYSTR"), str)
False
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!
Environs users I'm supporting just hit this:
What? Expected empty string, as explicitly set:
This violates reasonable assumptions that the type of the value returned by
env.foois alwaysfoo, as is otherwise consistent withenv.bool,env.int,env.float, etc.:In this use case, the user should not need to know what a
marshmallow.missingis, 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 withmarshmallow.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!