-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Description
Feature or enhancement
Proposal:
Hey.
(Assuming this isn't a major feature, I've skipped the "Major feature proposals should generally be discussed on Discourse before opening a GitHub issue.". 😇)
I have code like:
with warnings.catch_warnings(record=True) as w:
long_running_func()
#handle w
where long running func may give back some warnings for which I use custom types that are derived from UserWarning
.
After the function, these warnings are somehow handled.
But in principle, I'd only like to catch only certain types of warnings... and the others should ideally be "let through" normally (i.e. per default, printed immediately, and not only when I'd e.g. handle and re-emit it manually during my post-function handling).
So perhaps, something like a catch_categories
parameter, which then might be a sequence type, and would cause the context manager to only catch those that are instances of the given categories?
Thanks for consideration,
Chris.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response