sloria / environs

simplified environment variable parsing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default values defined in casted types

lucas-bremond opened this issue · comments

Before I submit a PR, would the maintainer be open to allowing the following construct?

ttl = env.timedelta("TTL", default=600)  # Currently works
ttl = env.timedelta("TTL", default=timedelta(minutes=10))  # Raises `environs.EnvValidationError`

The concept could be extended to other types, too: i.e., when the default value is provided in the already casted/output type, then use it as-is.

I think it'd make the interface nicer because expressing durations (for instance) only in seconds is less declarative than using a natural timedelta construct (especially when dealing with more complex durations).

Thoughts?

related: #270