Skip to content

Add fallback parameter support to config()#182

Open
kev1101-ux wants to merge 1 commit intoHBNetwork:masterfrom
kev1101-ux:add-fallback-parameter
Open

Add fallback parameter support to config()#182
kev1101-ux wants to merge 1 commit intoHBNetwork:masterfrom
kev1101-ux:add-fallback-parameter

Conversation

@kev1101-ux
Copy link

This PR adds an optional fallback parameter to the config() call in decouple.py.

1.If a configuration key is missing and no default is given, fallback will be returned instead of raising an error.

2.fallback is returned as-is (no casting), which makes it different from default.

3.Existing behavior remains unchanged when fallback is not used.

4.The change is fully backward compatible and limited to a single file.

Example:
from decouple import config

value = config("MISSING_KEY", fallback="Backup Value")

This is useful for development, testing, or optional settings where missing environment variables should not cause the application to crash.

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

Successfully merging this pull request may close these issues.

1 participant