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

Add argument raise_error_if_not_found for read_env #165

Closed
wants to merge 4 commits into from

Conversation

reorx
Copy link

@reorx reorx commented Aug 6, 2020

  • raise IOError when env file not found, this is an essential feature for serious deployment that should not run when the file is missing
  • print if env file is found or not when verbose=True

- raise IOError when env file not found, this is an essential feature for serious deployment that should not run when the file is missing
- print if env file is found or not when verbose=True
Looks that raise_error_if_not_found cannot be passed to find_dotenv
through load_dotenv

This reverts commit f906fd5.
@sloria
Copy link
Owner

sloria commented Oct 31, 2020

I'd rather not add this API surface for this. It's simple to do a check before running .read_env, if necessary.

from pathlib import Path
from environs import Env

env = Env()
if not Path(".env").exists():
    raise IOError("Missing .env file")
env.read_env(".env")

@sloria sloria closed this Oct 31, 2020
@reorx
Copy link
Author

reorx commented Nov 1, 2020 via email

@sloria
Copy link
Owner

sloria commented Nov 1, 2020

I think this is something I'd rather follow python-dotenv's lead on. If python-dotenv adds behavior to raise on a missing file, I'd be more willing to add it to environs.

It looks like there have been attempts to add such an API, but nothing has landed yet.

theskumar/python-dotenv#164
theskumar/python-dotenv#263

@reorx
Copy link
Author

reorx commented Nov 1, 2020 via email

@rptaylor
Copy link

@reorx now there is #311 for this instead.

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

Successfully merging this pull request may close these issues.

None yet

3 participants