-
Notifications
You must be signed in to change notification settings - Fork 81
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
I'd rather not add this API surface for this. It's simple to do a check before running from pathlib import Path
from environs import Env
env = Env()
if not Path(".env").exists():
raise IOError("Missing .env file")
env.read_env(".env") |
I don’t think so, the .env file is the dependency of Env class, it is okey
to silently fail, but it is also necessary to provide a way to explicitly
check the existence of the env file, otherwise it would be very difficult
to find out when the file is mistakenly put.
Yes you can make it with a few lines of code, but that doesn’t mean it’s a
right choice not to include it in the library.
On Sun, Nov 1, 2020 at 07:05 Steven Loria ***@***.***> wrote:
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 Pathfrom environs import Env
env = Env()if not Path(".env").exists():
raise IOError("Missing .env file")env.read_env(".env")
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#165 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADDDVGC3ZKIXOGTFSEX7ZDSNSJ2NANCNFSM4PW4SNZQ>
.
--
青松虽苦寒,羞逐桃李春
|
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. |
You’re right, actually I was surprised python-dotenv didn’t implement it at
the beginning, but my habit is to complete the missing feature, or correct
the misbehaving one in higher level library, so just through the issue here
:)
On Sun, Nov 1, 2020 at 12:04 Steven Loria ***@***.***> wrote:
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#164>
theskumar/python-dotenv#263
<theskumar/python-dotenv#263>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#165 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADDDVG56EQQISYJKHK2S4DSNTM5PANCNFSM4PW4SNZQ>
.
--
青松虽苦寒,羞逐桃李春
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.