-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
Use env var to disable loading dotenv #2724
Conversation
I need to add a test case. |
flask/cli.py
Outdated
@@ -544,7 +544,10 @@ def main(self, *args, **kwargs): | |||
# script that is loaded here also attempts to start a server. | |||
os.environ['FLASK_RUN_FROM_CLI'] = 'true' | |||
|
|||
if self.load_dotenv: | |||
val = os.environ.get('FLASK_DONT_LOAD_ENV') | |||
load_dotenv = not val or val in ('0', 'false', 'no') |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Oops. Tests should not fail since I didn't add any changes to break the test. Weird. |
@davidism any idea why tests failed? I've tested master branch on my local machine, tests failed too. |
I can take a look tomorrow. The most common issue I had with CLI tests was that a test would forget to reset the env vars. Not sure if that's related here. |
The weird thing is master branch's tests fail on my local machine. |
Working on this. Changed base to 1.0-maintenance. |
flask/cli.py
Outdated
@@ -544,7 +544,10 @@ def main(self, *args, **kwargs): | |||
# script that is loaded here also attempts to start a server. | |||
os.environ['FLASK_RUN_FROM_CLI'] = 'true' | |||
|
|||
if self.load_dotenv: | |||
val = os.environ.get('FLASK_DONT_LOAD_ENV') | |||
load_dotenv = not val or val in ('0', 'false', 'no') |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Needs a test. |
Shouldn't it be called "FLASK_IGNORE_DOTENV" or "FLASK_SKIP_DOTENV" ? "Flask don't load env" it's not exactly accurate because the flag purpose is to skip reading variables from .env, not to skip the shell environment. |
Discussion at #2722, it was chosen to match pipenv's |
Added the check to |
Fix issue: #2722