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

fail if specified .env file does not exist #294

Closed
rptaylor opened this issue Jun 21, 2023 · 2 comments
Closed

fail if specified .env file does not exist #294

rptaylor opened this issue Jun 21, 2023 · 2 comments

Comments

@rptaylor
Copy link

Previously discussed in #199

See theskumar/python-dotenv#297

It looks like now there is https://github.com/theskumar/python-dotenv/pull/388/files which will cause load_dotenv to return false if no vars were read:

import dotenv
a=dotenv.load_dotenv('no.env', verbose=True)
print(a)
False

So for the reasons previously described it would be good to have a way in environs to force a failure if the specified env file does not exist, by e.g. checking the return code from dotenv and raising an exception if it is false.

@sloria
Copy link
Owner

sloria commented Jan 10, 2024

#311 modifies env.read_env to return False if the file is not found. This allows users to handle that case as they see fit, e.g. raise an exception, log a warning.

Closing this for now. Thanks for the suggestion!

@sloria sloria closed this as completed Jan 10, 2024
@rptaylor
Copy link
Author

Great , thanks @sloria !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants