Skip to content

Cannot parse dict with bool subtypes #38

@lukasvida

Description

@lukasvida

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions