-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MNT: print missing font warning only once per font. #26602
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
base: main
Are you sure you want to change the base?
Conversation
I’ve not following the details here, but if this is only about suppressing expected warnings in the doc builds, a warnings filter in conf.py would be the way to go. |
Not sure how since we want one warning per missing font to print out at once. I tried using the once filter and couldn't get that working. |
Ah sorry, I was thining about I would base deduplication on the message. Separate ids is more effort than it's worth. Likely the simplest approach is to wrap your logging in use a |
Going down that rabbit hole, it looks like the least extra/most generalizable may be to make a custom loghandler or use a handler filter (which is what I'm trying now) |
So uh adding a filter works really nicely, and I can move it to the sphinxextensions - there's one for missing references I used as a model-but I think the multiple prints are annoying in any context. Only problem is it works a bit too well and I can't get the messages to show up on new runs -> any tips for resetting the msg_cache on new runs? |
lib/matplotlib/font_manager.py
Outdated
@@ -50,6 +50,26 @@ | ||
|
||
_log = logging.getLogger(__name__) | ||
|
||
|
||
class findfontFilter(logging.Filter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider making this a private class, as this is internal functionality added to an already private logger.
(This is what stubtest
is complaining about, as it sees this as public but not added to the stub files)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, made those changes locally but didn't push cause I'm still struggling w/ clearing the msg_cache
Wrapping the log calls in a check that the missing font isn't in a list of missing fonts. Goal is to make the doc builds easier to read by squashing the extra prints.
I have it separated out my msg cause I'm not sure if that's important, could totally see easier versions that check if the entire msg has been seen (so stores a list of msgs) or that only looks at font and not the msg. base on call convo w/ @ksunden