Skip to content

Is it possible for a config variable to reference another one inside of a config class? #93

@OmarEjjeh

Description

@OmarEjjeh

I'm trying to get something like the following pseudocode to work:

class AppConfig:
    root: str = environ.var(default="/data/", converter=str)
    folder: str = AppConfig.root + "subfolder/"


cfg = environ.to_config(AppConfig)

The expected behaviour being that I can type cfg.folder and get the string "/data/subfolder/" back. Basically, I want to be able to set values on the cfg object on the basis of other values that are populated by environment variables. I use this pattern all the time in my code - it's especially useful when you want to set a root folder using an environment variable and then specify a bunch of subfolders relative to that root.

Is there any way of accomplishing this?

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