Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Change (or at least document) surprising behavior parsing env var when explicitly set to empty string #71
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
>>> isinstance(env.str("MYSTR"), str) False
In this use case, the user should not need to know what a
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!