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

Cannot parse dict with bool subtypes #38

Open
lukasvida opened this issue Mar 20, 2021 · 0 comments
Open

Cannot parse dict with bool subtypes #38

lukasvida opened this issue Mar 20, 2021 · 0 comments

Comments

@lukasvida
Copy link

I haven't found a way to parse dictionary with boolean subtypes.
The variable in .env file is:
FOO=bar1=true, bar2=false
and I parse it with env.dict('FOO', subcast=bool).

Expected result is
{'bar1':True, 'bar2':False}
but I get
{'bar1':True, 'bar2':True} instead.

The reason why this happens is that subcast is called as constructor and dict value is read as string so bool('false') evaluates to True.

The only way I found this working is specifing variable as
FOO=bar1=true, bar2=, but this would be too messy if i had more dict keys.

Another way to parse it as desired is to specify environment variable as json, but I don't want to do that.

@lukasvida lukasvida changed the title Cannot parse dict of bool values Cannot parse dict with bool subtypes Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant