Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default values defined in casted types #297

Open
lucas-bremond opened this issue Aug 22, 2023 · 1 comment
Open

Default values defined in casted types #297

lucas-bremond opened this issue Aug 22, 2023 · 1 comment

Comments

@lucas-bremond
Copy link

lucas-bremond commented Aug 22, 2023

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?

@fdemmer
Copy link

fdemmer commented Jan 16, 2024

related: #270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants