-
Notifications
You must be signed in to change notification settings - Fork 408
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 .env file is not found #321
Comments
I understand the return response for There are other ways to get around this for you use case.
It feel like exposing an instance of |
I think it would be OK to return So I'd suggest implementing that, or changing strategies and adding a
Although it could lead to interesting features, I'm worried that exposing the About returning |
@theskumar why we can access values from .env files by just os.getenv("VARIABLE_NAME") without even calling load_env() ? Any reason? |
load_env sets the environment variables of the python instance to the ones found in the file. If you don't call I, then it uses the local variables of the system. |
This modifies Dotenv.set_as_environment_variables to return False if we have not discovered any environment variables via either `dotenv_path` or `stream`. This return value gets passed through to `load_dotenv`, so this can be used to determine if `dotenv.load_dotenv` was able to set anything. Closes theskumar#321
This modifies Dotenv.set_as_environment_variables to return False if we have not discovered any environment variables via either `dotenv_path` or `stream`. This return value gets passed through to `load_dotenv`, so this can be used to determine if `dotenv.load_dotenv` was able to set anything. Closes theskumar#321
This modifies Dotenv.set_as_environment_variables to return False if we have not discovered any environment variables via either `dotenv_path` or `stream`. The return value gets passed through to `load_dotenv`, so this can be used to determine if `dotenv.load_dotenv` was able to set anything. Closes theskumar#321
I've submitted a PR that changes the behavior of |
This modifies Dotenv.set_as_environment_variables to return False if we have not discovered any environment variables via either `dotenv_path` or `stream`. The return value gets passed through to `load_dotenv`, so this can be used to determine if `dotenv.load_dotenv` was able to set anything. Closes theskumar#321
This modifies Dotenv.set_as_environment_variables to return False if we have not discovered any environment variables via either `dotenv_path` or `stream`. The return value gets passed through to `load_dotenv`, so this can be used to determine if `dotenv.load_dotenv` was able to set anything. Closes theskumar#321
I think this is the same or similar to #297 ? |
…388) * Fix docstring for load_dotenv The docstring for load_dotenv was missing a word, rendering it confusing. This commits modifies it for clarity. * Return False when we do not discover any environment variables This modifies Dotenv.set_as_environment_variables to return False if we have not discovered any environment variables via either `dotenv_path` or `stream`. The return value gets passed through to `load_dotenv`, so this can be used to determine if `dotenv.load_dotenv` was able to set anything. Closes #321 Co-authored-by: Saurabh Kumar <theskumar@users.noreply.github.com>
This behaviour is not ideal since if the configuration file is not found in the filesystem it may be better to return False.
In this way the user can write something like:
Steps to reproduce
The text was updated successfully, but these errors were encountered: