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

Allow preventing or suppressing UserWarning #12

Open
jpadilla opened this issue Mar 31, 2015 · 6 comments
Open

Allow preventing or suppressing UserWarning #12

jpadilla opened this issue Mar 31, 2015 · 6 comments

Comments

@jpadilla
Copy link
Owner

We use dotenv on our project/wsgi.py and project/celery.py for local development where we do have a .env. When we deploy to Heroku our logs get polluted with UserWarnings.

Workaround is to do the following:

with warnings.catch_warnings():
    warnings.simplefilter('ignore')
    dotenv.read_dotenv()
@chris-erickson
Copy link

Is this a suggestion how we should suppress it, or how the code might be modified? We get this warning all over the place and it would be great to eliminate it.

@jpadilla
Copy link
Owner Author

@chris-erickson this is a suggestion on how to suppress it in your app. We could provide an option like dotenv.read_dotenv(silent=True) and skip the warning. Pull requests are welcome.

@tgroshon
Copy link

We had some discussions in PR #23 about ways to prevent the warning:

@merwok
A complementary idea would be to use logging instead of warnings. Logging is more appropriate according to https://docs.python.org/2/howto/logging.html#when-to-use-logging and easy to configure.
@tgroshon
I also like the idea of replacing warnings with logging. Then a user could specify their log level easily in different environments (DEBUG in development or testing, WARNING in production, etc.).

@dhrp
Copy link

dhrp commented Jun 18, 2017

I know this thread has been dead, but we'd like the suppress mode, and as far as I can tell it is not solved.

@jpadilla
Copy link
Owner Author

I'm down with reviewing a PR that uses logging instead of warnings like discussed in #23.

@merwok
Copy link
Contributor

merwok commented Feb 13, 2018

FTR at my company we have written a small lib to abstract various settings systems including dotenv; no warnings! https://github.com/caravancoop/configstore/

Pplum09 pushed a commit to Pplum09/django-dotenv that referenced this issue Feb 14, 2020
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

5 participants