You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
lukasvida
changed the title
Cannot parse dict of bool values
Cannot parse dict with bool subtypes
Mar 20, 2021
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 toTrue
.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.
The text was updated successfully, but these errors were encountered: