Config.from_file() was missing errno.ENOTDIR in its silent error
handling, while Config.from_pyfile() correctly includes it.
When a component of the config file path is a regular file rather
than a directory (e.g., trying to load 'file/config.json' where
'file' is a regular file), from_file(silent=True) would raise an
OSError instead of silently returning False.
This adds ENOTDIR to match from_pyfile's behavior and adds a test
to verify the fix.
Fixes#5912
This new method will pick out any environment variables with a certain
prefix and place them into the config named without the prefix. This
makes it easy to use environment variables to configure the app as is
now more popular than when Flask started.
The prefix should ensure that the environment isn't polluted and the
config isn't polluted by environment variables.
I've followed the dynaconf convention of trying to parse the
environment variable and then falling back to the raw value if parsing
fails.
TOML is a very popular format now, and is taking hold in the Python
ecosystem via pyproject.toml (among others). This allows toml config
files via,
app.config.from_file("config.toml", toml.loads)
it also allows for any other file format whereby there is a loader
that takes a string and returns a mapping.