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

Don't throw IOError for missing .env file #10

Closed
lachlancooper opened this issue Feb 9, 2018 · 3 comments · Fixed by #15
Closed

Don't throw IOError for missing .env file #10

lachlancooper opened this issue Feb 9, 2018 · 3 comments · Fixed by #15

Comments

@lachlancooper
Copy link

First of all thanks very much for this beautiful library, I'm using it to replace a few others as well as a lot of manual type-casting.

I would like to suggest making read_env() only opportunistically search for a .env file, and do nothing (or perhaps log a warning) if no file is found. This is the way django-environ, envparse, and python-dotenv all work.

I think it makes sense to support .env files in situations where there is no better way to manage environment variables, such as running an application locally, but not require them when running in production under, say, Docker or a traditional process manager.

I can of course work around this with a simple try/catch, but a change like this would make the library even nicer to use.

@sloria
Copy link
Owner

sloria commented Feb 9, 2018

Thanks for the kind words.

I'm open to this suggestion. If it's the convention to pass silently, then we should probably do the same.

PR's welcome! =)

@euphoria
Copy link

I don't know whether it is convention or not, so I don't want to impose it on this library without knowing, but for what it's worth I manually use

try:
    env.read_env(recurse=True)
except IOError:
    pass

myself as well.

sloria added a commit that referenced this issue Aug 5, 2018
This is more consistent with expected behavior, and is consistent
with django-environ and envparse

close #10
@sloria sloria closed this as completed in #15 Aug 5, 2018
sloria added a commit that referenced this issue Aug 5, 2018
This is more consistent with expected behavior, and is consistent
with django-environ and envparse

close #10
@sloria
Copy link
Owner

sloria commented Aug 5, 2018

In 3.0.0, a warning is raised instead of an error.

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

Successfully merging a pull request may close this issue.

3 participants