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

Comments

@lec00q
Copy link

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

This comment has been minimized.

Copy link
Member

commented Oct 10, 2018

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

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

Source

@jacquerie

This comment has been minimized.

Copy link

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.

@lec00q

This comment has been minimized.

Copy link
Author

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.

@greyli

This comment has been minimized.

Copy link
Member

commented Oct 11, 2018

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

@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

@miguelgrinberg miguelgrinberg added question and removed question labels Jan 13, 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

Merge pull request #2939 from sharmaadarsh563/2937-correct-load_doten…
…v-return-value

Fix #2937: Ensure the consistency in load_dotenv's return type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.