Flask: Add a parameter to disable load dotenv using Flask CLI

Created on 27 Apr 2018  路  8Comments  路  Source: pallets/flask

Running Flask CLI with pipenv using the new version(1.0)

pipenv run flask run

I always get the tip message about the load_dotenv feature. Since pipenv already load the .env file, It might be interesting have some parameter to disable Flask to load .env and does not show the tip message.

Expected Behavior

Disable load dotenv using the Flask CLI. Example:

pipenv run flask run --ignore-dotenv

Or just remove the tip message and let it only in the documentation.

Actual Behavior

Showing the dotenv tip message even if the developer doesn't want to use it
* Tip: There are .env files present. Do "pip install python-dotenv" to use them

Environment

  • Python version: 3.6.4
  • Flask version: 1.0
  • Werkzeug version: 0.14.1
cli

Most helpful comment

I'm going with FLASK_SKIP_DOTENV, as suggested in the PR. I think it more clearly describes what's happening.

All 8 comments

The tip is harmless to you since you know that you have loaded .env with pipenv. It is useful to other people, they have a .env file, but .env seems not work.

I see his point though, this kind of "tip" gets very annoying quickly when you see it on every startup...

pipenv is using: PIPENV_DONT_LOAD_ENV

$ PIPENV_DONT_LOAD_ENV=1 pipenv shell

How about we use FLASK_DONT_LOAD_ENV.

@lepture I like the idea to use the same approach as pipenv with enviroment variable instead to add a new parameter

Thoughts on FLASK_LOAD_ENV=0 instead of FLASK_DONT_LOAD_ENV=1?

@davidism that seems weird to me. If an env var is not set, I think its value is None/False.

I'm going with FLASK_SKIP_DOTENV, as suggested in the PR. I think it more clearly describes what's happening.

me i have when the pop up tip messages comes what should i use

Was this page helpful?
0 / 5 - 0 ratings