-
-
Notifications
You must be signed in to change notification settings - Fork 309
Description
Describe the bug
When FLASK_APP is set in the environment then the CLI attempts to load the configuration from the Flask application. However an application is not detected - even if the environment variable is correctly set and works with the flask CLI command.
It appears an attempt was made to fix a similar issue in #705 (fixed in #774) however at least in my current environment and with the latest versions of Flask and Dynaconf (2.3.2 and 3.1.12 respectively at the time of this post) it does not seem to find the Flask application.
To Reproduce
Steps to reproduce the behavior:
- Set the
FLASK_APPenvironment variable
export FLASK_APP=myapp:app
- Execute one of the Dynaconf CLI commands
dynaconf list
Expected behavior
The command should be executed, loading the configuration instance from the Flask application.
The fix?
It looks like:
is a bare instantiation of ScriptInfo, and app_import_path is never set. In Flask's own code:
https://github.com/pallets/flask/blob/cb825687a592709f902f3d320d93987a0546fd28/src/flask/cli.py#L393
the variable is being set with a callback on the app command-line option which then will result in being set from FLASK_APP. Since this code branch relies on the environment variable being set, I don't see why we can't just pass it here.
I'll make a pull request shortly.
Unless -i is to become a compulsory option, the we might need to update the syntax to support callables/factories with :
Environment (please complete the following information):
- OS: Linux/Ubuntu20.04
- Dynaconf: 3.1.12
- Flask: 2.3.2