-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
after importing dtale, all python warnings are filtered out #668
Comments
@hottwaj so I was thinking up my solution being that I'd add Let me know the specific warning that you weren't seeing but wanted to so I can test it to make sure it won't affect that. |
Thanks and makes sense, though it might be safer to use the catchwarnings context manager as that will restore warnings to previous state when context exits: As well as warnings from internal libraries developed at my employer (I realised something was up when those stopped appearing), I do find it useful to see the usual array of pandas warnings for misuse/deprecated usage. I think suppressing all warnings is a bit too big of a hammer because then you just don't know what you are missing :) Anyway understand your need. Maybe an alternative suggestion would be to use a warnings filter + context manager with a regex for exactly the warnings you want to suppress? That way you'll still be able to spot any new warnings that might contain useful info. Thanks for the great library by the way, awesome work :) |
So the warning I'm trying to hide is for
but because it has newlines in it the regex filter isn't working. I've tried doing:
but that still seems to take out too much. Thanks for your help |
I tested and maybe the issue was that record=True stops output of all warnings to stdout? The docs are a bit unclear but I think that is what it is saying here: https://docs.python.org/3/library/warnings.html#warnings.catch_warnings The snippet below I think has the behaviour needed: with warnings.catch_warnings():
warnings.filterwarnings("ignore", '\nThe dash_html_components package is deprecated. Please replace\n`import dash_html_components as html` with `from dash import html`')
# this warning will be filtered
warnings.warn('\nThe dash_html_components package is deprecated. Please replace\n`import dash_html_components as html` with `from dash import html`')
warnings.warn('this will still be visible')
# this also does not produce a warning
import dash_html_components as html
warnings.warn('this and next warning should be visible!')
warnings.warn('\nThe dash_html_components package is deprecated. Please replace\n`import dash_html_components as html` with `from dash import html`') Slightly fragile I suppose as dash might change their deprecation message :) I guess you are using Thanks! |
that worked perfect! Thank you. I'll have this added and a new release soon. Will keep you posted |
@hottwaj just released v2.5.1 with this fix. Also, if you haven't already, please toss your ⭐ on the repo. Thanks 🙏 |
Awesome thanks v much, and ⭐️done! Cheers |
This library should not automatically filter out all warnings!
This line of code needs to be removed:
https://github.com/man-group/dtale/blob/master/dtale/__init__.py#L5
If specific warnings need to be filtered out, a more precise filter should be used?
Thanks!
The text was updated successfully, but these errors were encountered: