Allow preventing or suppressing UserWarning
See original GitHub issueWe 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()
Issue Analytics
- State:
- Created 8 years ago
- Reactions:5
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to disable Python warnings? - Stack Overflow
Look at the Temporarily Suppressing Warnings section of the Python docs: If you are using code that you know will raise a warning,...
Read more >warnings — Warning control — Python 3.11.1 documentation
Temporarily Suppressing Warnings¶ ... While within the context manager all warnings will simply be ignored. This allows you to use known-deprecated code without ......
Read more >Suppress Warnings In Python: All You Need To Know
Suppress warnings in python; warnings and types, ignore all warnings, ignore specific warnings, re-enable warnings.
Read more >Disable UserWarning s triggered by dependencies #1737
I think UserWarnings that are triggered by Haystack's or the user's code should stay visible, but those coming from dependencies could be hidden ......
Read more >Control (ignore/display) warnings in Python - nkmk note
If you want to stop the process for warnings like exceptions, set action of warnings.simplefilter() to 'error' . warnings.resetwarnings() ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@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.