You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package is very useful, thanks!
I noticed something while testing opening a .env file that does not exist:
$ python
Python 3.9.1 (default, Dec 18 2020, 05:16:04)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from environs import Env
>>> env = Env()
>>> env.read_env("nothing.env", verbose=True)
>>> env("VAR")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/home/.local/lib/python3.9/site-packages/environs/__init__.py", line 80, in method
raise EnvError('Environment variable "{}" not set'.format(proxied_key or parsed_key))
environs.EnvError: Environment variable "VAR" not set
There is no error message or warning when calling read_env on a file that does not exist - even with verbose=True !
Instead, the environment variables you may have expected will just be absent. Is this intended?
This could cause your application to perhaps silently behave differently than expected.
IMO if there is a problem the failure should be immediate and obvious instead of deferred and quiet.
So if you explicitly specify the env file that you want, there should be an exception if it doesn't exist.
This way it can be detected earlier, before the application starts running and getting environs.EnvError from missing variables. Moreover this clearly distinguishes between two different problems: some lines missing from the .env file, or the whole .env file missing altogether.
So instead it seems I will have to write some error handling to detect if the env file exists before calling read_env. Not sure about the design reasoning but thought it might be helpful if environs could handle that instead.
Hello,
This package is very useful, thanks!
I noticed something while testing opening a .env file that does not exist:
There is no error message or warning when calling read_env on a file that does not exist - even with verbose=True !
Instead, the environment variables you may have expected will just be absent. Is this intended?
This could cause your application to perhaps silently behave differently than expected.
IMO if there is a problem the failure should be immediate and obvious instead of deferred and quiet.
So if you explicitly specify the env file that you want, there should be an exception if it doesn't exist.
This way it can be detected earlier, before the application starts running and getting environs.EnvError from missing variables. Moreover this clearly distinguishes between two different problems: some lines missing from the .env file, or the whole .env file missing altogether.
So instead it seems I will have to write some error handling to detect if the env file exists before calling read_env. Not sure about the design reasoning but thought it might be helpful if environs could handle that instead.
I note that upstream dotenv has this line but not sure why it isn't being invoked:
https://github.com/theskumar/python-dotenv/blob/master/src/dotenv/main.py#L65
The text was updated successfully, but these errors were encountered: