envparse icon indicating copy to clipboard operation
envparse copied to clipboard

Cannot parse dict with bool subtypes

Open lukasvida opened this issue 4 years ago • 0 comments

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 avatar Mar 20 '21 09:03 lukasvida