Skip to content
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

load_dotenv returns true even if no file exists #2937

Closed
lec00q opened this issue Oct 10, 2018 · 4 comments
Closed

load_dotenv returns true even if no file exists #2937

lec00q opened this issue Oct 10, 2018 · 4 comments
Milestone

Comments

@lec00q
Copy link

@lec00q lec00q commented Oct 10, 2018

Expected Behavior

If no file is loaded/exists, flask.cli.load_dotenv should return False.

Actual Behavior

This code:

from flask import Flask
from flask.cli import load_dotenv

app = Flask(__name__)
result = load_dotenv('not-exist')
assert result

does not fail.

Environment

  • Python version: 3.5.5
  • Flask version: 1.0.2
  • Werkzeug version: 0.14.1
@greyli
Copy link
Member

@greyli greyli commented Oct 10, 2018

IMO, it's a default behavior of python-dotenv:

>>> from dotenv import load_dotenv
>>> load_dotenv('nothing')
>>> True

Source

Loading

@jacquerie
Copy link

@jacquerie jacquerie commented Oct 10, 2018

it's a default behavior of python-dotenv:

That's true, but the docstring promises a different thing:

:return: ``True`` if a file was loaded.

Loading

@lec00q
Copy link
Author

@lec00q lec00q commented Oct 10, 2018

I was in fact referring to that promise. As a side note, I think that it also make sense, but this is just a personal opinion.

Loading

@greyli
Copy link
Member

@greyli greyli commented Oct 11, 2018

Maybe we can change this line to something like "True if a file was loaded or path is not None."?

Loading

@greyli greyli added the docs label Oct 11, 2018
sharmaadarsh563 added a commit to sharmaadarsh563/flask that referenced this issue Oct 11, 2018
sharmaadarsh563 added a commit to sharmaadarsh563/flask that referenced this issue Oct 11, 2018
sharmaadarsh563 added a commit to sharmaadarsh563/flask that referenced this issue Oct 11, 2018
@davidism davidism added this to the 1.1 milestone Jan 7, 2019
@davidism davidism removed the docs label Jan 7, 2019
davidism added a commit to sharmaadarsh563/flask that referenced this issue May 19, 2019
davidism added a commit that referenced this issue May 19, 2019
…v-return-value

Fix #2937: Ensure the consistency in load_dotenv's return type
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants